Return a reference by a class function and return a whole object in c++?
问题 Operator overloading in class CVector: CVector CVector::operator+ (CVector param) { CVector temp; temp.x = x + param.x; temp.y = y + param.y; return (temp); } and in main: CVector a (3,1); CVector b (1,2); CVector c; c = a + b; So an object is passed by value, and then another temp object is being created. I guess b is being passed by value, a is the one calling the + therefore the x and y belong to a and pram.x and param.y to b. temp is returned and the the copy assignment operator delivers