【发布时间】:2020-07-14 23:39:42
【问题描述】:
在以下代码中:
int main() {
int i, j;
j = 10;
i = (j++, j+100, 999+j);
cout << i;
return 0;
}
输出为 1010。
但是不应该是 1009,因为 ++ 应该在使用整个表达式之后完成吗?
【问题讨论】:
-
相关:参见 Why are these constructs using pre and post-increment undefined behavior? 和 Order of evaluation,并阅读 C++11 中引入的“序列点”。
标签: c++ comma post-increment