文章目录 自增运算时的差异示例代码输出结果原因分析 自增运算时的差异 示例代码 #include <iostream> using namespace std; int main() { int i = 0; int j = i++ + i; cout << j << endl; system("pause"); return 0; } 输出结果 g++ 输出:1 MSVC 输出:0 原因分析 通过阅读 求值顺序 文档发现 C++ 中无从左到右或从右到左求值的概念,此外该差异属于 未定义行为(undefined behavior,UB)。