#include <iostream>
using namespace std;
class Point {
private:
int x;
int y;
public:
Point() { };
// 在此处补充你的代码
friend ostream & operator<< (ostream & o, Point & p){
cout<<p.x<<","<<p.y;
return o;
}
friend int operator >>(istream & i,Point & p){
cin>>p.x>>p.y;
return 1;
}
};
int main()
{
Point p;
while(cin >> p) {//关键是重载>>和<<
cout << p << endl;
}
system("pause");
return 0;
}
mooc 016openjudge 惊呆!Point竟能这样输入输出 对<<和>>的重载
最新推荐文章于 2024-08-12 16:55:46 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)