What do you mean by ‘Return by Reference’ in C++ ?
A function can be declared to return a pointer or a reference. When the function is returning a reference, the calling function receives the lvalue for the variable. The calling function can then modify the variable or take its address.
If the return value is a large class object, using a reference (or pointer) return type is more efficient than returning the class object by value. In some cases, the compiler can automatically transform a return by value to a return by reference.
E.g.
Complex& compute (Complex c)
{
Complex *tmp = new Complex ();
// …
return tmp;
}However care should be exercised when returning a reference to a local object. The lifetime of the local object terminates with the termination of the function. The reference is left aliasing undefined memory after the function terminates.

Nez
is it not "return *tmp;"? (ref rather than ptr)
I doubt usefullness of this construct. By using ptr instead you state that result is now owned by caller and is less confusing.
The answer to orig question b.t.w. could relate more to returning value in reference-declared call argument....
Nez
Ok, there is such thing. Mostly used to lvalue the global objects. This is a very bad code but it gives the point;
====