参考意外的输出考虑代码:使用通通过在C++
#include<iostream>
using namespace std;
int refcube(double &ra)
{
ra*=ra*ra;
return ra;
}
int main()
{
auto x=2.0;
cout<<"cube of "<<x<<" is "<<refcube(x)<<endl;
return 0;
}
的输出是:
cube of 8 is 8
为什么的x
在第一值被显示为8
代替2
?
这里的一些答案http://stackoverflow.com/questions/14809978/order-of-execution-in-operator – SnoozeTime