Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class Point {
- private:
- int x, y;
- public:
- Point() {}
- Point(int _x, int _y) {
- x = _x;
- y = _y;
- }
- Point operator + (Point tmp) {
- return Point(x + tmp.x, y + tmp.y);
- }
- Point operator - (Point tmp) {
- return Point(x - tmp.x, y - tmp.y);
- }
- Point operator * (Point tmp) {
- return Point(x * tmp.x, y * tmp.y);
- }
- Point operator / (Point tmp) {
- return Point(x / tmp.x, y / tmp.y);
- }
- void pechati() {
- cout << x << " " << y << endl;
- }
- };
- int main()
- {
- Point a(3, 4);
- Point b(5, 6);
- Point c = a + b;
- c.pechati();
- Point c2 = a - b;
- c2.pechati();
- Point c3 = a * b;
- c3.pechati();
- Point c4 = a / b;
- c4.pechati();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement