在std库中 cout<< 是右结合的,下面用代码来证明:
![]()
#include <iostream>
int whole=20;
int addwhole()
{
whole+=8;
return whole;
}
int subwhole()
{
whole-=9;
return whole;
}
void main()
{
std::cout<<addwhole()<<" "<<subwhole()<<std::endl;
int i = 10;
std::cout << i++<< "一 " << i-- <<" 二"<<i--<<" 三"<<i--<<" 四"<<i--<<std::endl;
}
输出结果如下:
本文通过C++代码展示了cout<<的右结合性,并详细解释了运算符结合性的概念和证明过程。


被折叠的 条评论
为什么被折叠?



