this Pointer

Any class member function (unless it is static) has the possibility to use the this pointer. this points to the object the function belongs to.

Example


#include <iostream>
using namespace std;

class AClass
{
public:
     int a;
     AClass(int x)
     {
        this->a = x; // is equivalent to a = x;
     }
};

int main()

{
     AClass obj1(86);
}