Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

Const references :

It is possible to declare a const reference. A const reference will not let you
change the value it references:
int nValue = 5;
const int &rnRef = nValue;
rnRef = 6; // illegal -- rnRef is const

Constant Ref . used in Pass by const reference : You already know that a const reference is a referenc
e that does not allow the variable being referenced to be changed.
Consequently, if we use a const reference as a parameter, we guarantee to the c
aller that the function will not (and can not) change the argument!

You might also like