You're trying to apply the prefix ++
operator to the result of the expression a++
. The result of a++
is a temporary value and thus not assignable, i.e. it is not an lvalue. Since you're only allowed to use ++
on lvalues, you get the error that you get.
Somewhat interesting side note: The result of a++
is an rvalue in both C and C++. However the result of ++a
is an lvalue in C++, but not in C. So if you changed your code to say (++a)++
, your code would work in C++, but not in C.