- 论坛徽章:
- 0
|
原帖由 kiffa 于 2008-10-12 23:48 发表 ![]()
说实话,我一直都不是很清楚对于i++ 这种,具体是什么时候才实行自增。
因为我不清楚表达式的严格定义。。。
对于语句:
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).
其他的 标准未定义 |
|