D
Dave Rahardja
Hi all,
Although the following definition is legal:
const int& i = 5;
....and that the lifetime of the temporary variable to which i refers is
identical to i itself, why would anyone want to do this instead of a simple
const int i = 5;
....?
I can see how binding a const reference to a temporary object is necessary
(such as when passing an rvalue to a function expecting a const reference),
but the above usage perplexes me.
-dr
Although the following definition is legal:
const int& i = 5;
....and that the lifetime of the temporary variable to which i refers is
identical to i itself, why would anyone want to do this instead of a simple
const int i = 5;
....?
I can see how binding a const reference to a temporary object is necessary
(such as when passing an rvalue to a function expecting a const reference),
but the above usage perplexes me.
-dr