And what object is that? I'm still confused so let me take this step by step:
a,b,c are declared as instances of the CVector class (c doesn't have any values for its constructor so c's x and y are going to be garbly gook, right?):
1 2 3
|
CVector a (3,1);
CVector b (1,2);
CVector c;
|
c gets the value of a+b so it's using the overloaded operator +
1 2 3 4 5 6 7 8
|
c = a + b;
//....
CVector CVector::operator+ (CVector param) {
CVector temp;
temp.x = x + param.x;
temp.y = y + param.y;
return (temp);
}
|
CVector gets instanced again as temp (again, temp's x and y are not initialized with some specific value)
So the only x and y values that you know the value of is a's and b's.
cout << x << " " << y; prints out "3, 1" and cout << param.x << " " << param.y; prints out "1,2".
The "1,2" I get (it's b that has been "passed" from the main function in c = a+b) but I don't get how "3, 1" aka a.x and a.y got there...