Hi, as a beginner of C++ I found the C++ Language Tutorial on this site is extremely helpful. As I progress through the tutorial, I seemed to get stuck at the Classes (II) section with these lines of code:
x and y are the data members of a CVector class object. When data members appear directly in a member function they are the members of the object calling the function (this).
In your example x and y are the same as this->x and this->y
The function could be written like this as well:
1 2 3 4 5 6
CVector& CVector::operator= (const CVector& param)
{
this->x=param.x;// explicit use of this pointer
this->y=param.y;
return *this;// the data members were just assigned above
}
I went over the section again and figured it out with help from your comments. I got sidetracked by analyzing too much the content of the function. As fun2code stated: x and y are the data members of a CVector class object. That piece of code was to demonstrate the use of "this"...