According to Eckel2000,
(see details in chapter 8 p351 and
chapter 11 p451), the first choice when passing an argument is to pass
by const reference:
- reference => avoid pass by value, which means
copy of data by creation of a temporary variable (always const).
- const => input
argument can be a const and particularly
a return value of another function.
This should be clear by reading the following example extracted from Eckel2000 p 352:
class X
X f() {return X(); } // return by value
void g1(X&) {} // Pass by non-const reference
void g2(const X&) {} // Pass by const reference
int main()
{
g1(f()); // Error: const temporary created by f()
g2(f()); // ok
}