class Complex {
public:
Complex(const double r,
const double i) {
re = r;
im = i;
}
Complex& operator+=(const Complex& a) {
re += a.re;
im += a.im;
return *this;
}
friend Complex operator+(const Complex& a,
const Complex& b) {
return Complex(a.re+b.re,
a.im+b.im);
}
private:
double re,
im;
};
void f(const Complex& a,
const Complex& b) {
Complex p = a + b; // short hand
Complex q = a.operator+(b); // oo way
Complex r = operator+(a,b); // explicit call
}