Advertisement
Josif_tepe

Untitled

Nov 3rd, 2023
818
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.55 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.     void print() {
  25.         cout << this->x << " " << this->y << endl;
  26.     }
  27. };
  28.  
  29. int main() {
  30.        
  31.     Point p1(1, 2);
  32.     Point p2(2, 3);
  33.     p1 += p2;
  34.    
  35.     p1.print();
  36.    
  37.     return 0;
  38. }
  39.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement