Accessing the object
The second statement in the function named classMain
reads as follows:
ptrToObject -> doSomething();
In layman's terms, this is what that statement means:
- Go to the pigeon hole in memory named ptrToObject
and extract a copy of the address that you will find there.
(This is analogous to going to the county tax office to learn
the address of a particular house.)
- Go to the location in memory that corresponds to that
address. There you will find the object. (This is
analogous to driving to the location of the house at the address that you
got from the county tax office.)
- Knock on the door of the object. When the person who
lives there answers the door, ask her to execute her public function
named doSomething, which she will do. (This
is analogous to knocking on the door of the house and asking the occupant to
do something. In the real world, however, she may refuse to do what you
ask.)