Using References as Return Types

References can also be used as return types for functions. The reference returns the lvalue of the object to which it refers. This allows you to place function calls on the left side of assignment statements.

C++Referenced return values are used when assignment operators and subscripting operators are overloaded so that the results of the overloaded operators can be used as actual values.

Note:
Returning a reference to an automatic variable gives unpredictable results.

Related References

IBM Copyright 2003