Why is ++x a lvalue
I am guessing it is an lvalue because it can be.
++x
it can be thought of as
((x = x + 1), x) // Increment x. Then evaluate to the value of x
or
((x += 1), x) // Increment x. Then evaluate to the value of x
It makes sense to evaluate ++x
to an lvalue.
x++ a rvalue?
Because it can't be an lvalue.
x++
it can be thought of as
((unnamed_variable = x), (x = x + 1), unnamed_variable)
or
((unnamed_variable = x), (x += 1), unnamed_variable)
x++
evaluates to the value of before x
is incremented. Since there is no variable that can store that value, it cannot be an lvalue.