int x;
int fun1()
{
x=x+10;
return x;
}
int main()
{
x=5;
cout<<x;
cout<<fun1();
}
这产生图5和15,同时多个语句产生不同的结果
cout<<x<<fun1();
这产生15和15请说明。 Thankyou
int x;
int fun1()
{
x=x+10;
return x;
}
int main()
{
x=5;
cout<<x;
cout<<fun1();
}
这产生图5和15,同时多个语句产生不同的结果
cout<<x<<fun1();
这产生15和15请说明。 Thankyou
看到这个答案进行评估的顺序:在您的输出http://stackoverflow.com/questions/10782863/what-is-the-correct-answer-for-cout-cc – Gerriet
插入新行为清楚起见。现在输出将是例如515没有\ n。 – Brandin
如果你写出实际的['operator <<'](http://en.cppreference.com/w/cpp/io/basic_ostream/operator_ltlt2)在定义时调用它,它可能会更清晰。尝试将它们编写为嵌套函数调用。对于Gerriet所链接的问题所选择的答案在这样做时会有详细的说明。 – WhozCraig