Cvector::operator+ just means that you want to define operator+ that is part of the class Cvector. You can use this technique to define any member function outside the class definition. If you had defined operator+ inside the class definition it would have looked something like this:
1 2 3 4 5 6 7 8 9 10 11 12
class CVector {
public:
int x,y;
CVector () {};
CVector (int a,int b) : x(a), y(b) {}
CVector operator+(const CVector& param) {
CVector temp;
temp.x = x + param.x;
temp.y = y + param.y;
return temp;
}
};
Your understanding of what happens seems to be right. An alternative way of writing line 25 is result = foo.operator+(bar);.
param is a reference to the second operand (bar). The operator is called on the first argument (this points to the first operand) so x and y are therefore the coordinates of the first operand (foo).