What is this pointer in Cpp?

All QuestionsCategory: Cpp LanguageWhat is this pointer in Cpp?
Chetan Shidling Staff asked 5 years ago

I need short information.

1 Answers
Chetan Shidling Staff answered 5 years ago

This Pointer in Cpp

  1. this represents an object that invokes a member function.
  2. It is a pointer that points to the object for which this function was called.
  3. this pointer is used for retrieving the current object address.
  4. It is used to distinguish between the data members and the local variables when both are declared with the same name.
  5. Static variables do not contain this pointer. Thus every nonstatic variable is used with this pointer.