Lecture 2 - Slide 15 : 29
References - Examples

Here we show a number of examples that illustrate various aspects of references

"The absence of const in a declaration of a reference (argument) is taken as a statement of intent to modify the variable"

A variable becomes a reference to another variable.
No operator operates on a reference as such.
A typical use of references: A number of results passed back from vector_min_max via references.
A function that attempts to return references to local variables.
Ditto - handling the problem by making the local variable static.
A function with reference parameters and reference return type.
Convenient references to long/deep fields.
The The C++ Prog. Lang. (4. edition) example on page 192-193 is also very illustrative
Go to exercise
Another example/exercise with C++ references
Go to exercise
Pointers in combination with references