Lecture 2 - Slide 14 : 29
Rules for references
int k = 3; double a = 5.0; double
&d
= a; void f(int
&i
, double
&d
); f(k,a);
A reference must be initialized when declared
A reference is constant by nature
Once established the reference can never be set to reference something else
No operator operates on a reference as such - only the object referenced
There is no null reference (in the sense that there is a
nullptr
)
Pointers to references and arrays of references do not exist
But references to pointers and references to array can exists
The C++ Prog. Lang. (3. edition)
:
Page 146
The C++ Prog. Lang. (4. edition)
: Page 316