On May 4, 8:04 pm, "Victor Bazarov" <v.Abaza...@comAcast.netwrote:
Temporaries are NOT const.
Except when they are:-). Temporaries are rvalues, and rvalues
are funny beasts in C++. An rvalue of non class type doesn't
have const-ness (or volatile-ness); it's neither const nor
non-const. An rvalue of class type can be either const or
non-const; like everything else, it is non-const by default, but
if you qualify it as const, it becomes const.
We tend to think of them as non-const, because in many context,
there's no way to qualify them as const. In the actual example,
however, the reason the temporary is not const is because it
wasn't declared const. Had the function been declared:
A const f() ;
, the temporary would have been const.
--
James Kanze (Gabi Software) email:
ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34