Jump to content
  • Advertisement
Sign in to follow this  
jenny_wui

Coud any one explain me the following code "self"

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

Hello, I am not familiar with the following assignment:

 

 

Manager &m = Manager::self();

 

Could any one clarify me ?

 

Thanks in advance.

 

Share this post


Link to post
Share on other sites
Advertisement

It's a call to static member function in class Manager called self which returns a Manager or Manager&.

 

Looks like it's a singleton.

 

EDIT: Manager is a terrible name for a class though, what does it manage?

Edited by Paradigm Shifter

Share this post


Link to post
Share on other sites

Can't quite tell; not enough code.  I am going to go out on a limb here and say it is a Singleton pattern implementation -- especially if it returns a manager (pointer) or reference.  Singleton is a pattern that states that there is one instance of an object that is shared by the entire program.  In which case, the manager class contains a static instance to that class, a private constructor, and an overloaded assignment operator.  In this case, you would be fetching the shared instance.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!