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 ...

Get Sams Teach Yourself C++ in 24 Hours, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.