// 23重载输出运算符
/*
#include <iostream>
using namespace std;
class A
{
public:
	A(int x, int y){
	    rx = x;
		ry = y;
	}
//private:
	int rx;
	int ry;
};
ostream&operator<<(ostream&s, const A&c)
{
	s<<c.rx<<" ";
	s<<c.ry<<endl;
	return s;
};

int main()
{
	A a(3,4), b(5,6);
    cout<<a<<b<<endl;
    return 0;
	//这就是返回ostream类对象cout的作用,按位左移动算符<<可以连续使用,由于每次都会返回一个cout,所以中间不用加cout
	//注意:由于cout是另一个类ostream的对像,ostream类没有公有和复制构造函数,因此函数无法调用该类的复制构造函数复制对象,必须按引用方式按受ostream的对像并且按引用方式返因ostream对象

}*/

  

相关文章:

  • 2022-01-02
  • 2021-05-18
  • 2022-12-23
  • 2022-12-23
  • 2021-08-04
  • 2021-05-21
  • 2021-05-09
  • 2021-06-06
猜你喜欢
  • 2021-09-30
  • 2021-08-01
  • 2021-05-23
  • 2021-12-03
  • 2021-10-07
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案