Tell me if im right :)

See this:

if (!GameEngine::GetEngine()->Initialize(iCmdShow))

I know this is calling the Initialize function, but is it doing it in the following way:

The GetEngine(), which is a member function in the GameEngine class (hence the scope resolution operate), returns m_pGameEngine, which is a pointer to the GameEngine class. From the pointer which points to the GameEngine class we point to the Initialize function which is in the GameEngine class.

Can you tell me if im correct in saying that please.

Also, is there not a simpler way of doing that, like putting GameEngine.Initialize() to call the Initialize() (I know that dont work, but you know what I mean).
It is a *static* function in the GameEngine class (hence the scope operator).

Other then that, you have it correct.

As for a simpler way of doing it, it looks like GameEngine is a singleton class so I don't think you could. If you just had a pointer to a GameEngine type, then you could just do: the_ptr->Initialize(iCmdShow) but you don't so...
That is very close.

Based solely on what you have posted, I would guess1 that GetEngine() is a static2 member function (probably a singleton3) in the GameEngine class. It returns a pointer (most likely to a GameEngine instance). The instance has a member function called Initialize that appears to return some kind of status (bool?).

Given that, the snippet reads something like this in plain English: "If the GameEngine has failed to initialize ..."


1 This syntax could also be used for a GameEngine namespace that contains a GetEngine() function.
2 Static methods can be called (usually from outside the class) using the scope resolution operator (::). If the method were not static, it would likely use "." or "->".
3 The Singleton design pattern mandates that no more than 1 instance of a class can be created at a time and that the instance is globally accessible. This indirection can also be used for defer object creation, etc..
Last edited on
:D
Topic archived. No new replies allowed.