CS Electrical And Electronics
@cselectricalandelectronics

What is this pointer in Cpp?

All QuestionsCategory: Cpp LanguageWhat is this pointer in Cpp?
CS Electrical And Electronics Staff asked 4 years ago

I need short information.

1 Answers
CS Electrical And Electronics Staff answered 4 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.