C++ - lvalue vs rvalue

Updated: 2021-05-13
lvalue rvalue
may appear on the left or right hand side of an assignment only on the right hand side of an assignment
refers to a memory location; can take the address of it via the & operator cannot get the address

For example: a, b and c are lvalues, while a * b is an rvalue:

int a = 1; // a is a lvalue
int b = 2; // b is a lvalue

a = b; // ok
b = a; // ok
a = a * b; // ok
int c = a * b; // ok
a * b = 42; // error, rvalue cannot be on the left hand side of assignment

Literal value: pure rvalue or prvalue