Can someone explain to me the (*this) pointer and demonstrate how it would be used as far as an object calling another object of the same class. What I don’t understand is how you would refer to two numbers in a member function of different 2 different objects of the same variable name. For example, multiplying two numbers.
a.Multiply(b);
//....
Numbers::Numbers Multiply(Numbers auggend)
{
}
The member functions of every object have access to a pointer named
this,which points to the object itself.When we call a member function,it comes into existence with the value ofthisset to the address of the object for which it was called.Using athispointer any member function can find out the address of the object of which it is a member.It can also be used to access the data in the object it points to. Example: