fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct Point {
  5. int x;
  6. int y;
  7.  
  8. Point(int _x, int _y):
  9. x(_x), y(_y) {
  10. }
  11.  
  12. Point& operator+ (const Point &other) {
  13. this->x += other.x;
  14. this->y += other.y;
  15. return *this;
  16. }
  17. };
  18.  
  19. int main() {
  20. Point p1(1, 0);
  21. Point p2(2, 3);
  22.  
  23. Point p3 = p1 + p2;
  24.  
  25. cout << p3.x << " " << p3.y << endl;
  26.  
  27. return 0;
  28. }
Success #stdin #stdout 0s 3096KB
stdin
Standard input is empty
stdout
3 3