When were Lvalue references introduced in C++?
A google search for this question returns for me articles with emphasis on Rvalue references. My question is about Lvalue references (a single &).
In what version of C++ were they introduced?
“l-value” refers to a memory location that identifies an object. “r-value” refers to the data value that is stored at some address in memory. References in C++ are nothing but the alternative to the already existing variable. They are declared using the '&' before the name of the variable.
lvalue simply means an object that has an identifiable location in memory (i.e. having an address). In any assignment statement “lvalue” must have the capability to store the data. lvalue cannot be a function, expression (like a+b) or a constant (like 3 , 4 , etc.).
An lvalue (locator value) represents an object that occupies some identifiable location in memory (i.e. has an address). rvalues are defined by exclusion. Every expression is either an lvalue or an rvalue, so, an rvalue is an expression that does not represent an object occupying some identifiable location in memory.
An lvalue refers to an object that persists beyond a single expression. An rvalue is a temporary value that does not persist beyond the expression that uses it.
References were present in the first edition of "The C++ Programming Language" in 1985, before the language was standardized.
But they existed since it was renamed from "C with Classes" to "C++" in 1983.
See 3.3 in http://www.stroustrup.com/hopl2.pdf.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With