Advertisement
Josif_tepe

Untitled

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