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

 1 #include <iostream> 
 2 using namespace std;
 3 class Point { 
 4     private: 
 5         int x; 
 6         int y; 
 7     public: 
 8         Point() { };
 9 friend istream& operator>>(istream& is,Point& p){
10             is >> p.x >> p.y;
11             return is;
12         }
13         friend ostream& operator<<(ostream& os,Point& p){
14             os << p.x << "," << p.y;
15             return os;
16         }
17 }; 
18 int main() 
19 { 
20      Point p;
21      while(cin >> p) {
22          cout << p << endl;
23      }
24     return 0;
25 }

 

posted @ 2022-09-13 22:37  balabalahhh  阅读(28)  评论(0编辑  收藏  举报