Advertisement
Josif_tepe

Untitled

Mar 22nd, 2021
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.67 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <stack>
  4. #include <fstream>
  5. #include <algorithm>
  6.  
  7. using namespace std;
  8.  
  9. class Point {
  10. private:
  11.     int x;
  12.     int y;
  13. public:
  14.     Point(int x = 0, int y = 0) {
  15.         (*this).x = x; // this->x = x; isto e
  16.         (*this).y = y; // this->y = y; isto e
  17.     }
  18.    
  19.    
  20.     void soberi(Point p) {
  21.         this->x += p.x;
  22.         this->y += p.y;
  23.     }
  24.     int get_x() const {
  25.         return x;
  26.     }
  27.     int get_y() const {
  28.         return y;
  29.     }
  30.    
  31. };
  32. int main()
  33. {
  34.     Point p(10, 10);
  35.     Point u(20, 20);
  36.  
  37.     p.soberi(u);
  38.     cout << p.get_x() << " " << p.get_y() << endl;
  39.      
  40.     return 0;
  41. }
  42.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement