#include <iostream>
using namespace std;
class Complex
{
double real, imag;
public:
Complex(double r, double i) :real(r), imag(i) { };
Complex operator+(double r);
friend Complex operator+ (double r, const Complex& c);
void print() { cout << real << " " <<imag << endl; }
};
Complex Complex::operator+(double r)
{ //能解释 c+5
return Complex(real + r, imag);
}
Complex operator+ (double r, const Complex& c)
{ //能解释 5+c
return Complex(c.real + r, c.imag);
}
int main()
{
Complex a(1, 1);
a.print();
a = 5+a;
a.print();
}