i=1为何(++i)+(++i)=6?
#include "iostream" #include "algorithm" #include "bits/stdc++.h" using namespace std; int main(){ int i=1; cout<<(++i)+(++i)<<endl; //system("pause"); return 0; }
为何结果是6呢?
()内的运算优先级高于 + ,先计算两个++i, 两个++i执行完 i=3, 3+3 =6
以下内容来自https://www.sojson.com/operation/cxx.html