Advertisement
STANAANDREY

op ov

Feb 16th, 2020
318
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.42 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. class ComplexNr
  6. {
  7. public:
  8.     int x, y;
  9.  
  10.     ComplexNr (int x, int y)
  11.         : x(x), y(y) {};
  12.  
  13.     ComplexNr operator +(const ComplexNr& other) const
  14.     {
  15.         return ComplexNr(this -> x + other.x, this -> y + other.y);
  16.     }
  17. };
  18.  
  19. int main ()
  20. {
  21.     ComplexNr p1(1, 1), p2(5, 3);
  22.     ComplexNr p = p1 + p2;
  23.     cerr << p.x << ' ' << p.y;
  24.     return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement