class Complex { public: Complex(double re, double im) : real(re), imag(im) {} ... friend Complex operator+(Complex& a, Complex& b); private: double real; double imag; } |
Complex operator+(Complex& a, Complex& b) { Complex ret(a.real + b.real, a.imag + b.imag); return ret; } |
class Complex { public: Complex(double re, double im) : real(re), imag(im) {} ... Complex operator+(Complex& b); private: double real; double imag; } |
Complex Complex::operator+(Complex& b) { Complex ret(this->real + b.real, this->imag + b.imag); return ret; } |
Leo Liberti 2008-01-12