Chris Mantoulidis said:
Why is that? Why does ++x return lvalue and x++ return rvalue?
for example, this will work
++x = 10;
it will set x to 10...
but this won't, cuz x++ is rvalue:
x++ = 10; //ERROR
TIA,
cmad
It should be noted that ++x=10; is undefined for inbuilt types, as stated in
section 5.0.4 of the standard:
Between the previous and next sequence point a scalar object shall have its
stored value modified at most once by the evaluation
of an expression. Furthermore, the prior value shall be accessed only to
determine the value to be stored.
The requirements of this paragraph shall be met for each allowable ordering
of the subexpressions of a full
expression; otherwise the behavior is undefined. [Example:
i = v[i++]; // the behavior is unspecified
i = 7, i++, i++; // i becomes 9
i = ++i + 1; // the behavior is unspecified
i = i + 1; // the value of i is incremented
-end example]