#include <iostream>
struct complex {
double a;
double b;
complex(double _a = 0, double _b = 0)
: a(_a), b(_b) {}
const complex operator+(const complex& rhs) {
return complex(a + rhs.a, b + rhs.b);
}
const complex operator*(const complex& rhs) {
double c = rhs.a;
double d = rhs.b;
return complex(a * c - b * d, a * d + b * c);
}
friend std::ostream& operator<<(std::ostream& os, const complex& c) {
return os << "(" << c.a << ", " << c.b << ")";
}
friend std::istream& operator>>(std::istream& is, complex& c) {
return is >> c.a >> c.b;
}
};
Comments
Dear stanley, to run the code you need main()
How would you run the above code ? it doe not seem to work on my side ?
Leave a comment