The this Pointer
Every class member function has a hidden parameter: the this pointer. this points to the individual object. Therefore, in each call to GetAge() or SetAge(), the this pointer for the object is included as a hidden parameter.
The job of the this pointer is to point to the individual object whose method has been invoked. Usually, you don't need this; you just call methods and set member variables. Occasionally, however, you'll need to access the object itself (perhaps to return a pointer to the current object). It is at that point that the this pointer becomes so helpful.
Normally, you don't need to use the this pointer to access the member variables of an object from within methods of that object. You can, however, explicitly call ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access