Advertisement
Josif_tepe

Untitled

Dec 10th, 2024
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.73 KB | None | 0 0
  1.  
  2. class Point {
  3. private:
  4.     int x, y;
  5. public:
  6.     Point() {}
  7.     Point(int _x, int _y) {
  8.         x = _x;
  9.         y = _y;
  10.     }
  11.     Point(const Point & tmp) {
  12.         x = tmp.x;
  13.         y = tmp.y;
  14.     }
  15.     ~Point() {}
  16.    
  17.     Point operator + (Point tmp) {
  18.         Point res(x + tmp.x, y + tmp.y);
  19.         return res;
  20.     }
  21.    
  22.     Point operator - (Point tmp) {
  23.         Point res(x - tmp.x, y - tmp.y);
  24.         return res;
  25.     }
  26.    
  27.     Point operator * (Point tmp) {
  28.         Point res(x * tmp.x, y * tmp.y);
  29.         return res;
  30.     }
  31.     Point operator / (Point tmp) {
  32.         Point res(x / tmp.x, y / tmp.y);
  33.         return res;
  34.     }
  35.     void print() {
  36.         cout << x << " " << y << endl;
  37.     }
  38.    
  39. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement