Does postfix increment perform increment not on returned value?
问题 Again, a silly question. #include <stdio.h> #include <iostream> using namespace std; int main() { int i = 0; i = i++; cout<<i; return 0; } I get 1 printed as a result of this program though I expected 0: first a temp object created eing equal 0, then i is incremented, then temp object is returned and assigned to i. Just according to: 5.2.6 Increment and decrement [expr.post.incr] 1 The value obtained by applying a postfix ++ is the value that the operand had before applying the operator.