return by reference - which of the two is the correct one
- by eriks
i have the function: const A& f(...) {...}
a. const A a1 = f(..);
b. const A &a2 = f(...);
which of the is the better one to use? in both cases, if i understand correctly, i prevent the possibility of modifying the returned object.
in the first option, the copy constructor of A will be called - am i correct?