Sign in to follow this  

Namespace issues

This topic is 3666 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi guys, I'm having some issues with namespaces.. Here's a snippet of the problem code. In Pickup.h:
#include "Level.h"

namespace codename
{
	class Pickup
	{
		public:
			virtual VOID PickedUp(Level* theLevel) = 0;
	};
}

Now if i try to compile this the compiler complains - syntax error : identifier 'Level'
namespace codename
{
	class Level
	{
		public:
			Level();			
	};
}

I'm using Visual C++ 2005 Express and if i change the parameter to (codename::Level* theLevel) i get - 'Level' : is not a member of 'codename' This is strange as if i type codename:: anywhere in the Pickup class IntelliSense proves that Level is in that namespace by showing the dropdown box with Level included in the list. If i include a vector of Pickups in the Level class everything goes haywire. I get - 'Pickup' : is not a member of 'codename' And in all the derived classes of Pickup, for example in WeaponPickup.cpp:
#include "WeaponPickup.h"

namespace codename
{
	...
	...
}

missing ';' before '{' As well as a whole bunch of other cascading errors. If anyone can help me out I'd appreciate it. - Cheers

Share this post


Link to post
Share on other sites
Compiles fine for me, after changing 'VOID' to 'void'...


main.cpp

#include "Pickup.h"

void main()
{

}



Pickup.h

#include "Level.h"

namespace codename
{
class Pickup
{
public:
virtual void PickedUp(Level* theLevel) = 0;
};
}



Source.h

namespace codename
{
class Level
{
public:
Level();
};
}



There should, of course, be include guards and a lot of other things added to this code.

Share this post


Link to post
Share on other sites

This topic is 3666 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this