我真的不知道后缀.我知道它首先使用标识符然后增加或减少,如第一次显示i然后++.但现在我认为我错了,仍然不明白.
#include <iostream>
using namespace std;
int main()
{
int i = 0;
cout << i << i++ << i;
cout << "\n\n\nPress Enter to close the window . . . ";
cin.clear();
cin.sync();
cin.get();
return 0;
}
Run Code Online (Sandbox Code Playgroud)
输出:
101
Press Enter to close the window . . .
Run Code Online (Sandbox Code Playgroud)
首先i在增量加入之前改变.为什么?
我期望
001
Press Enter to close the window . . .
Run Code Online (Sandbox Code Playgroud)
有人可以解释.
从来没有做过这样的事情,它是未定义的
cout << i << i++ << i;
Run Code Online (Sandbox Code Playgroud)
更好
cout << i << i << (i + 1);
i ++;
Run Code Online (Sandbox Code Playgroud)
如果你想要你的预期结果.
案子
cout << i++;
Run Code Online (Sandbox Code Playgroud)
定义完全正常.