【发布时间】:2021-02-06 03:48:29
【问题描述】:
为什么是下面的表达式:
total += *start++;
评估为:
total += (*start)++;
而不是:
total += *(start++); // though this doesn't really matter either it would be the same
++(后缀增量)和*(取消引用具有相同的优先级并且从右到左关联,那么为什么不首先评估++ 后缀?
或者,后缀是否在一个序列点之后计算,等等:
total += *++start
评估结果为:
total += *(++start)
但是因为后缀发生在:
total += *start++
评估结果为:
total += (*start)++;
换句话说,Right-to-Left 关联性在上述表达式中并不重要,因为即使在表达式求值期间,也不会计算后缀?
【问题讨论】:
标签: c operator-precedence