其他分享
首页 > 其他分享> > 016 惊呆!Point竟然能这样输入输出

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;
}

标签:pp,istream,temp,Point,int,输入输出,016,operator
来源: https://www.cnblogs.com/icefield817/p/15914039.html