this Pointer

this pointer :

  • The this pointer is a pointer accessible only within the nonstatic member functions of a class.
  • It points to the object for which the member function is called.
  • Static member functions do not have a this pointer.
e.g. :

OUTPUT: 

  • It can also be used to return as a pointer to that object from a function.
e.g. : 
 
OUTPUT :

 

Leave a Reply

Your email address will not be published. Required fields are marked *