Advertisement
Josif_tepe

Untitled

Mar 31st, 2021
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.66 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.     int get_x() {
  29.         return x;
  30.     }
  31.     int get_y() {
  32.         return y;
  33.     }
  34. };
  35.  
  36. int main() {
  37.  
  38.     Point p(1, 2);
  39.     p++;
  40.     p--;
  41.     cout << p.get_x() << endl;
  42.     cout << p.get_y() << endl;
  43.     return 0;
  44. }
  45.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement