operator/定义在complex类中,real,image均定义为private,double型
complex complex::operator/(complex &t)
{
complex c;
c.real=(real*t.real+image*t.image)/(t.real*t.real+t.image*t.image);
c.image(real*t.image*(-1)+image*t.real)/(t.real*t.real+t.image*t.image);
return c;
}
int main()
{
complex c1(10,2),c2(5,1),c3;
c3=c1/c2;
c3.display();
return 0;
}
程序运行输出20i.
我认为应输出2
请高手指教