I try to understand to the end the difference between return object and return reference to the object c++ . for example I Have class classA and I do something like this:
ClassA(){
classA Operator+(classA &){ // option 1
ClassA new_a;
return new_a;
}
classA & Operator+(classA &){ // option 2
ClassA new_a;
return new_a;
}
Main:
ClassA a1, a2, a3;
a3 = a1 + a2;
I will get the same result in the both options. but if I understand right it the first option it will copy the object bit by bit and in the second option it will return the object it self. but I'm not sure because the address of the object a3 still the same to the address when I create it in line 1.