Advertisement
Josif_tepe

Untitled

Mar 31st, 2021
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.83 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. class Point {
  6. private:
  7.     int x, y;
  8. public:
  9.     Point() {}
  10.     Point(int _x, int _y) {
  11.         x = _x;
  12.         y = _y;
  13.     }
  14.     Point(const Point &tmp) {
  15.         x = tmp.x;
  16.         y = tmp.y;
  17.     }
  18.     ~Point() {}
  19.    
  20.     Point& operator ++ (int p) {
  21.         x++;
  22.         return *this;
  23.     }
  24.     Point& operator -- (int p) {
  25.         y--;
  26.         return *this;
  27.     }
  28.     Point& operator = (const Point &tmp) {
  29.         x = tmp.x;
  30.         y = tmp.y;
  31.         return *this;
  32.     }
  33.     int get_x() {
  34.         return x;
  35.     }
  36.     int get_y() {
  37.         return y;
  38.     }
  39. };
  40.  
  41. int main() {
  42.  
  43.     Point p(1, 2);
  44.     Point p2(2, 3);
  45.     p = p2;
  46.     p++;
  47.     p--;
  48.     // (2, 3) --> (3, 2)
  49.     cout << p.get_x() << endl;
  50.     cout << p.get_y() << endl;
  51.     return 0;
  52. }
  53.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement