#include <iostream>
using namespace std;
class Complex
{
public:
Complex(double newx=0, double newy=0) { r = newx; i = newy; }
Complex operator+(const Complex& c) const { return Complex(r + c.r, i + c.i); }
void Display() {
if (i > 0)
cout << r << '+' << i << 'i' << endl;
else if (i < 0)
cout << r << i << 'i' << endl;
else
cout << r << endl;
}
private:
double r, i;
};
int main()
{
Complex a(2.1,5.7), b(7.5,8), c, d;
c = a + b;
d = b + 5.6;
c.Display();
d.Display();
return 0;
}
