Sign in to follow this  

kind of need some help in understanding some code....

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

can you tell me what this line of code is doing? template<> StateManager* Singleton<StateManager>::ms_Singleton = 0; ?? this is in the statemanager.cpp file. from what i can tell as of now, this class listens on the frames and checks what the user selects at the main menu i.e new game, help section, high score section, quit, etc...

Share this post


Link to post
Share on other sites
It looks like it define and initialize the static singleton variable of the Singleton<StateManager> class...

class A
{
public:
static int* ptr;
};

int* A::ptr = 0; // <-- this line is similar, but for a non template class

Share this post


Link to post
Share on other sites
ms_Singleton is a static pointer to a StateManager object.

All static variables that belongs to a class has to be defined and possibly initialized outside the class. (As in my example above)
Usually at the beginning of the corresonding cpp file.

They are different from normal class member variables, and should not be initialized in the constructor.

Share this post


Link to post
Share on other sites

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