#include <iostream>
using namespace std;
class Point {
private:
double x, y;
public:
Point(double x = 0, double y = 0) : x(x), y(y) {}
// Перегрузка оператора + (сложение двух точек)
Point operator+(const Point& other) const {
return Point(x + other.x, y + other.y);
}
// Перегрузка оператора == (сравнение двух точек)
bool operator==(const Point& other) const {
return (x == other.x) && (y == other.y);
}
// Для удобного вывода
friend ostream& operator<<(ostream& os, const Point& p) {
os << "(" << p.x << ", " << p.y << ")";
return os;
}
};
int main() {
Point p1(1, 2);
Point p2(3, 4);
Point p3 = p1 + p2;
cout << "p1 + p2 = " << p3 << endl; // (4, 6)
cout << "p1 == p2: " << (p1 == p2 ? "true" : "false") << endl; // false
cout << "p1 == p1: " << (p1 == p1 ? "true" : "false") << endl; // true
return 0;
}