2009-09-05
设计一个复数类,并实现二种(加法 乘法)运算方法?
#include#includeclassCComplex{ (doubler=0,doublei=0);CComplex(CComplex&c);CComplexoperator+(CComplexa);CComplexoperator*(CComplexm);friendostream&operator
#include#includeclassCComplex{ (doubler=0,doublei=0);CComplex(CComplex&c);CComplexoperator+(CComplexa);CComplexoperator*(CComplexm);friendostream&operator
imag=imag+a。imag;returnretVal;}CComplexCComplex::operator*(CComplexm){CComplexretVal;retVal。real=real*m。
real-imag*m。imag;retVal。imag=real*m。imag+imag*m。real;returnretVal;}ostream&operator