Jump to content
  • Advertisement
Sign in to follow this  
Juksosah

C++ experts : namespace VS static ?

This topic is 3668 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

Here's something I can't resolve :
namespace Util {

	class LinkedList{

         //stuff

	}
}
Every time I refer this class I must use Util::LinkedList because of the namespace. Fair enough. Now I got this :
//.h file
class aaa
{
public :
    static LinkedList* myList;

}
//.cpp file of class aaa
 
static ?????::LinkedList* myList = 0;
My question is simple : replace ????? by the correct syntax. It should be like this : static aaa::LinkedList* myList but because of the namespace the compiler complains that LinkedList is not a member of aaa. That syntax doesn't work either : static aaa::Util::LinkedList* myList Should I get rid of that $#?#$ namespace ??

Share this post


Link to post
Share on other sites
Advertisement
I think what you're looking for is:
class aaa
{
public :
static Util::LinkedList* myList;

}

// In .cpp:

Util::LinkedList aaa::myList = 0;
Also, be sure to look at the container classes offered by the SC++L (such as list).

Share this post


Link to post
Share on other sites
Quote:
Original post by Juksosah
It should be like this :
static aaa::LinkedList* myList

No it shouldn't. LinkedList isn't a member of the "aaa" scope. Did you mean static LinkedList* aaa::myList? The syntax to qualify the namespace should be clear there.

Share this post


Link to post
Share on other sites
Seems like my problem is solved.. I don't have access to the code right now, i'll try this tonight.

Thanks jyk again(If I remember well you helped me a lot in the past) and snetfel for correcting me.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!