- 論壇徽章:
- 0
|
原帖由 kiffa 于 2008-10-12 23:48 發(fā)表 ![]()
說實話,我一直都不是很清楚對于i++ 這種,具體是什么時候才實行自增。
因為我不清楚表達(dá)式的嚴(yán)格定義。。。
對于語句:
int i = 1;
int j = i++;
地球人都知道 j 等于 1,但是 i 的自增是什么時候 ...
6.5.2.4 Postfix increment and decrement operators
Constraints
1 The operand of the postfix increment or decrement operator shall have qualified or
unqualified real or pointer type and shall be a modifiable lvalue.
Semantics
2 The result of the postfix ++ operator is the value of the operand. After the result is
obtained, the value of the operand is incremented. (That is, the value 1 of the appropriate
type is added to it.) See the discussions of additive operators and compound assignment
for information on constraints, types, and conversions and the effects of operations on
pointers. The side effect of updating the stored value of the operand shall occur between
the previous and the next sequence point.
3 The postfix -- operator is analogous to the postfix ++ operator, except that the value of
the operand is decremented (that is, the value 1 of the appropriate type is subtracted from
it).
其他的 標(biāo)準(zhǔn)未定義 |
|