B
baumann.Pan
in the book the C++ program language , 5.5 :
references to variables and references to constants are distinguished
because the introduction of a temporary in the case of the variable is
highly error-pron;
an assignment to the variable would become an assignment to the - soon
to disappear - temporary. No such problem exists for references to
constants.
I don't understand it. just before the sentence, it says
const double & cdr = 1; //ok
the interprtation of it might be:
double temp = double(1);
const double & cdr = temp;
according to it, it seems to me it is reference to constant introuce
temporary not reference to variable.
references to variables and references to constants are distinguished
because the introduction of a temporary in the case of the variable is
highly error-pron;
an assignment to the variable would become an assignment to the - soon
to disappear - temporary. No such problem exists for references to
constants.
I don't understand it. just before the sentence, it says
const double & cdr = 1; //ok
the interprtation of it might be:
double temp = double(1);
const double & cdr = temp;
according to it, it seems to me it is reference to constant introuce
temporary not reference to variable.