【发布时间】:2012-08-13 21:26:22
【问题描述】:
请注意,这与 Operator Precedence.. () and ++ 、 Undefined behavior and sequence points 、 Why are these constructs (using ++) undefined behavior? 以及这里的数百个类似问题无关
简而言之:标准是否保证了关联性?
详细示例:来自Wikipedia关于运算符优先级的文章,operator*和operator/具有相同的优先级,它们是Left-to-right运算符。这是否意味着,标准保证,这:
int res = x / y * z / t;
将被评估为
int res = ( ( x / y ) * z ) / t;
还是定义了实现?
如果有保证,可以报价吗?
只是出于好奇,在这些情况下我总是写括号。
准备删除问题,如果有这样的问题。
【问题讨论】:
-
是的(现在需要一些字符!)
标签: c++ c operator-precedence associativity