Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When were Lvalue references introduced in C++?

Tags:

c++

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?

like image 726
becko Avatar asked Mar 25 '14 19:03

becko


People also ask

What is an lvalue reference?

“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.

What is an lvalue in C?

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.).

What is the difference between lvalue and rvalue in C?

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.

What's the difference between rvalue and lvalue?

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.


1 Answers

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.

like image 70
imreal Avatar answered Oct 28 '22 12:10

imreal