How do we explain the result of the [removed]++x)+(++x)+(++x)?

后端 未结 5 1660
滥情空心
滥情空心 2020-11-28 13:05
x = 1;
std::cout << ((++x)+(++x)+(++x));

I expect the output to be 11, but it\'s actually 12. Why?

5条回答
  •  感情败类
    2020-11-28 13:18

    The code snippet will invoke Undefined behavior in both C/C++.Read about Sequence Point from here.

提交回复
热议问题