Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
大家好,我需要一些帮助来了解这些复合赋值运算符的工作原理
int x=6; x += x -= x * x;
x 结果是-60 有人可以解释为什么以及如何工作吗?
忽略带有序列点的 UB:
x += x -= x * x;
是
(x += (x -= (x * x)));
所以
x * x->36
x * x
36
x -= 36->x = -30
x -= 36
x = -30
x += -30->x = -60
x += -30
x = -60