Advertisement
Josif_tepe

Untitled

Nov 18th, 2023
468
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. #include <iostream>
  2.  
  3.  
  4. using namespace std;
  5.  
  6. class Point {
  7. private:
  8.     int x, y;
  9.    
  10. public:
  11.     Point () {}
  12.     Point(int _x, int _y) {
  13.         x = _x;
  14.         y = _y;
  15.     }
  16.    
  17.     friend ostream & operator << (ostream & stream, Point p);
  18.     friend istream & operator >> (istream & stream, Point & p);
  19. };
  20.  
  21. ostream & operator << (ostream & stream, Point p) {
  22.     stream << p.x << " " << p.y << endl;
  23.     return stream;
  24. }
  25. istream & operator >> (istream & stream, Point  & p) {
  26.     stream >> p.x >> p.y;
  27.     return stream;
  28. }
  29. int main()
  30. {
  31.     Point p1;
  32.     cin >> p1;
  33.    
  34.     cout << p1;
  35.    
  36.     return 0;
  37. }
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement