Today I found very interesting definition of lvalue in C++. According to this site:
An lvalue is an expression that refers to a memory location and allows us to take the address of that memory location via the
&
operator. An rvalue is an expression that is not an lvalue.
Examples are:
// lvalues: // int i = 42; i = 43; // ok, i is an lvalue int* p = &i; // ok, i is an lvalue int& foo(); foo() = 42; // ok, foo() is an lvalue int* p1 = &foo(); // ok, foo() is an lvalue // rvalues: // int foobar(); int j = 0; j = foobar(); // ok, foobar() is an rvalue int* p2 = &foobar(); // error, cannot take the address of an rvalue j = 42; // ok, 42 is an rvalue
Comments
Post a Comment