Advertisement
Josif_tepe

Untitled

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