Coud any one explain me the following code "self"

Started by
2 comments, last by Khatharr 10 years, 6 months ago

Hello, I am not familiar with the following assignment:

Manager &m = Manager::self();

Could any one clarify me ?

Thanks in advance.

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?

"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley

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.

"The code you write when you learn a new language is shit.
You either already know that and you are wise, or you don’t realize it for many years and you are an idiot. Either way, your learning code is objectively shit." - L. Spiro

"This is called programming. The art of typing shit into an editor/IDE is not programming, it's basically data entry. The part that makes a programmer a programmer is their problem solving skills." - Serapth

"The 'friend' relationship in c++ is the tightest coupling you can give two objects. Friends can reach out and touch your privates." - frob

A singleton named manager...

Sounds like it should be renamed 'Monotheos'.

void hurrrrrrrr() {__asm sub [ebp+4],5;}

There are ten kinds of people in this world: those who understand binary and those who don't.

This topic is closed to new replies.

Advertisement