各位大神帮忙看下哪里出错了??
#include<iostream>#include<math.h>
using namespace std;
class fushu
{
private:
double x,y;
public:
fushu(double a=0,double b=1);
fushu add(fushu w);
fushu subtract(fushu w);
fushu multiply(fushu w);
fushu divide(fushu w);
fushu mo();
void show();
};
fushu::fushu(double a,double b)
{
x=a;
y=b;
}
fushu fushu::add(fushu w)
{
fushu z;
z.x=x+w.x;
z.y=y+w.y;
return z;
}
fushu fushu::subtract(fushu w)
{
fushu z;
z.x=x-w.x;
z.y=y-w.y;
return z;
}
fushu fushu::multiply(fushu w)
{
fushu z;
z.x=x*w.x-y*w.y;
z.y=x*w.y+y*w.x;
return z;
}
fushu fushu::divide(fushu w)
{
fushu z;
if(w.x==0&&w.y==0)
{
cout<<"作为分母的复数为0,不能相除"<<endl;
exit(0);
}
z.x=(x*w.x+y*w.y)/(w.x*w.x+w.y*w.y);
z.y=(y*w.x-x*w.y)/(w.x*w.x+w.y*w.y);
return z;
}
fushu fushu::mo()
{
fushu z;
z.x=sqrt(x*x+y*y);
z.y=0;
return z;
}
void fushu::show()
{
cout<<"复数为:"<<x<<"+"<<y<<"i"<<endl;
}
void main()
{
fushu a(1,2),b(3,4),t;
t=a.add(b);
t.show();
t=a.subtract(b);
t.show();
t=a.multiply(b);
t.show();
t=a.divide(b);
t.show();
t=a.mo();
t.show();
}