-> operator

My class defines a functions:

BOOL Initialize(int iCmdShow);

and uses it in the following way:

// Initialize the game engine
if (!GameEngine::GetEngine()->Initialize(iCmdShow))
return FALSE;

How does the -> function work?
-> is the same thing as a ".", just that you use it on pointers.
When used on a pointer:

1
2
some_ptr->data; //is the same as:
(*some_ptr).data;
Unless data is a pointer to a base class of something.
Thanks.

if (GameInitialize(hInstance))
{
// Initialize the game engine
if (!GameEngine::GetEngine()->Initialize(iCmdShow))
return FALSE;

What's going on here, I have an idea, but i like to make SURE im on the right track. Could you tell me in the english language instead of the c++ language :P

1
2
3
4
5
6
7
8
9
10
// Call the GameInitialize function. If it returns
// true, then...
if (GameInitialize(hInstance))
{
//Call the static function GetEngine of the class
//GameEngine. With the pointer that GetEngine returns,
//call the member function Initialize. If that function returns false,
//then...
if (!GameEngine::GetEngine()->Initialize(iCmdShow))
return FALSE;
Last edited on
Topic archived. No new replies allowed.