#include <iostream>
#include <string>
using namespace std;
class Complex {
public:
double real, imag;
Complex(double r = 0, double i = 0) {
real = r;
imag = i;
}
Complex operator+(Complex other) {
return Complex(real + other.real, imag + other.imag);
}
bool operator==(Complex other) {
return real == other.real && imag == other.imag;
}
}
ostream & operator<<(ostream& os, Complex c) {
os << c.real << " + " << c.imag << "i";
return os;
} class Vector2D {
private:
double x;
double y;
public:
Vector2D(double x = 0, double y = 0) : x(x), y(y) {} Vector2D operator*(double scalar) const {
return Vector2D(x * scalar, y * scalar);
}
class Student
{
bool operator>(const Student& other) const {
return gpa > other.gpa;
}
private:
string name;
double gpa;
public:
};
int main()
{
Complex c1(2, 3), c2(1, 4);
Complex sum = c1 + c2;
cout << "Sum: " << sum << endl;
(5, 7), 2(2, 3);
diff = -;
scaled = *3;
Student s1("Vova", 4.5), s2("Dima", 3.8);
if (s1 > s2) cout << " has higher GPA" << endl;
Complex c3(2, 3);
if (c1 == c3) cout << "Complex numbers are equal" << endl;
return 0;
}