TITLE: Increment operator and lvalues PROBLEM: pcwu@csie.nctu.edu.tw (Pei-Chi Wu) In ANSI C, both the return type of prefix ++/-- and postfix ++/-- are not lvalues. But in C++, the prefix ++/-- are redefined as returning lvalue. So you can write code like this: int i; ++ ++ i; but cannot write: int i; i ++ ++; (Increment and decrement can only be applied on lvalue.) What is the reason the language make prefix and postfix different? Why do the committee make C++ incompatible with ANSI C without meaningful improvements or advantages? RESPONSE: ark@europa.att.com (Andrew Koenig), AT&T Bell Laboratories Because the result of the expression ++i is `i' after incrementing, which can be viewed as equivalent to (++i, i) Since `i' is an lvalue, this expression can reasonably be treated as an lvalue. On the other hand, the result of the expression i++ must be a copy of the old value of `i,' since `i' no longer has that value. Since it is a copy, it must be a compiler-generated temporary, which is not an lvalue. The behavior you describe is not an incompatibility. Incompatibilies are cases where valid C programs behave differently in C++. Since neither i++ nor ++i is an lvalue in C, it is impossible to write a C program that detects the C++ behavior. Thus this behavior is a pure extension to C, much like almost all of the rest of C++.