Advertisement
Josif_tepe

Untitled

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