In C++, pre-increment operator gives lvalue because incremented object itself is returned, not a copy. But in C, it gives rvalue. Why?
See Question&Answers more detail:osIn C++, pre-increment operator gives lvalue because incremented object itself is returned, not a copy. But in C, it gives rvalue. Why?
See Question&Answers more detail:osC doesn't have references. In C++ ++i
returns a reference to i
(lvalue) whereas in C it returns a copy(incremented).
C99 6.5.3.1/2
The value of the operand of the pre?x ++ operator is incremented. The result is the new value of the operand after incrementation. The expression ++Eis equivalent to (E+=1).
‘‘value of an expression’’ <=> rvalue
However for historical reasons I think "references not being part of C" could be a possible reason.