object and pointer in c++ code example
Example 1: what is this pointer in c++
Every object in C++ has access to its own address through an important pointer called this pointer.
The this pointer is an implicit parameter to all member functions.
Therefore, inside a member function,
this may be used to refer to the invoking object.
Friend functions do not have a this pointer,
because friends are not members of a class.
Only member functions have a this pointer.
Example 2: pointer in c++
int* pointVar, var;
var = 5;
pointVar = &var;
cout << *pointVar << endl;
In the above code, the address of var is assigned to the pointVar pointer.
We have used the *pointVar to get the value stored in that address.