A variable is a name associated to a storage. When you define a variable you associates a symbol to a reserved storage. In a program you can use the name of a variable at different places. In an arithmetic expression, like a+1
, a
refers to the value stored in the memory associated to the symbol. When you use it in an assignment like a=3
, a
refers to the storage location.
When the symbol is used to denote the value, it is said to be an r-value (right value, value at the right of an assignment), when the symbol is used to denote the location, it is said to be an l-value (left value, value at the left of an assignment). In a=b
, a
is a l-value and b
a r-value.
You can only have l-values at the left of an assignment, alas a++
is an expression that denotes the value of the variable before the increment, not the location, so you can't put it on the left of an assignment.