Lecture 2 - Slide 16 : 29 |
A constant reference is really a reference to a constant
The use of const in a declaration of a reference (argument) means that we do not want to change the referenced object
"An initializer for const T& does not need to be an lvalue, or even of type T"
const T &var = expression;
![]() | A similar program that initializes a user defined struct via a 'functional casting' constructor. |
![]() | Use of a const reference in the vector_min_max function (alread encountered in this lecture). |
![]() | Illustrates that it is not good to return a const reference to a deallocated local variable. |