016 惊呆!Point竟然能这样输入输出

#include <iostream> 
using namespace std;
class Point { 
	private: 
		int x; 
		int y; 
	public: 
		Point() { };
friend istream& operator>> (istream & is,Point & pp) {
        int temp;
        cin >> temp;
        pp.x = temp;
        cin >> temp;
        pp.y = temp;
        return is;
    }
    friend ostream& operator<< (ostream & o,const Point & pp) {
        o << pp.x<<","<<pp.y;
        return o;
    }
}; 
int main() 
{ 
 	Point p;
 	while(cin >> p) {
 		cout << p << endl;
	 }
	return 0;
}
posted @ 2022-02-19 22:48  icefield817  阅读(76)  评论(0编辑  收藏  举报