表达式求值顺序不同于运算结合性和优先级。规则的核心在于 顺序点( sequence point )。在两个顺序点之间,子表达式求值和副作用的顺序是不确定的。假如代码的结果与求值和副作用发生顺序相关,我们称这样的代码有不确定的行为(unspecified behavior)。
你可以利用括号来改变数学的求值顺序。
You can change the mathematical order of evaluation by using brackets.
通常,操作数的求值顺序不会影响表达式的结果。
Often, the order of operand evaluation has no impact on the result of the expression.
如果所有操作符优先级一样,那么求值顺序就取决于它们的结合性。
If the operators all have the same precedence, then the order of evaluation depends on their associativity.
应用推荐