Lvalues & Rvalues

Lvalues are values that have a name and therefore an address, and persist beyond a single expression

 

Rvalues are temporary values that do not persist beyond the expression that uses it

 

int x ;

x = (2121 + 356) / (9 - 7) ;

 

The variable on the left hand side of the expression has been declared as an integer with a name of x, which has an associated memory address (that is accessible by &x ).

 

The values on the right hand side of the expression are literals and do not persist within memory when this expression has been completed.

 

If the values on the right hand side were presented as other variables, they would first be converted to Rvalues to be acted upon within that expression, e.g.:

 

int a = 2, b = 3, x ;

x = a + b ;

 

Although the a and b variables are Lvalues, but are implicitly converted from Lvalue to Rvalue within the expression.

 

  • lvalue equtes to an address
  • rvalue equates to a value

Leave a Reply