0
is it possible
x = 5; y = ++x++; // x is 6, y is 7
2 Antworten
+ 4
int y = ++x++;
// is equivalent to
int y = ++(x++);
// evaluates to
int y = ++(5);
and ++5 is not possible
The operand of an increment or decrement operator must be a variable, and here it is a constant so it is not possible
0
As a tip, to get your above statement to work, you may add brackets like this:
int y = (++x)++;
This works as ++x is still an lvalue while x++ is a rvalue. Since you can only perform increment on an lvalue and not on an rvalue, this works.
For details on why ++x is an lvalue and x++ isn't, visit this:
https://stackoverflow.com/questions/371503/why-is-i-considered-an-l-value-but-i-is-not