//有复数类Complex,利用运算符重载实现复数的加、减、乘、除等复数运算。 #include using namespace std; class Complex { private: double r,i; public: Complex(double R=0,double I=0):r(R),i(I){}; Complex operator+(Complex b); Complex operator-(Complex b); Complex operator*(Complex b); Complex operator/(Complex b); void display(); }; Complex Complex::operator +(Complex b) { return Complex(r+b.r,i+b.i); } Complex Complex::operator -(Complex b) { return Complex(r-b.r,i-b.i); } //求复数相乘的算法 Complex Complex::operator *(Complex b) { Complex t; t.r=r*b.r-i*b.i; t.i=r*b.i+i*b.r; return t; } //求复数相除的算法 Complex Complex::operator /(Complex b) { Complex t; double x; x=1/(b.r*b.r+b.i*b.i); t.r=x*(r*b.r+i*b.i); t.i=x*(i*b.r-r*b.i); return t; } void Complex::display(){ cout<0) cout<<"+"; if (i!=0) cout<