您的位置:首页 > 其它

哪里出错了。。。大侠帮帮忙啊

2010-12-27 10:57 176 查看
#include<iostream.h>

#include<math.h>

class complex

{

private:

double real;

double imag;

public:

complex()

{

real=0.0;imag=0.0;

}

complex(double r=0.0,double i=0.0)

{real=r;imag=i;}

~complex()

{

cout<<"destructing..."<<endl;

}

double realcomplex() {return real;}

double imagcomplex() {return imag;}

double abscomplex()

{

double t;

t=real*real+imag*imag;

return sqrt(t);

}

};

int main()

{

complex a(1.1,2.2);

cout<<"real of complex a="<<a.realcomplex()<<endl;

cout<<"image of complex a="<<a.imagcomplex()<<endl;

cout<<"abs of complex a="<<a.abscomplex()<<endl;

complex b;

cout<<"real of complex b="<<b.realcomplex()<<endl;

cout<<"image of complex b="<<b.imagcomplex()<<endl;

cout<<"abs of complex b="<<b.abscomplex()<<endl;

complex c(1.0);

cout<<"real of complex c="<<c.realcomplex()<<endl;

cout<<"image of complex c="<<c.imagcomplex()<<endl;

cout<<"abs of complex c="<<c.abscomplex()<<endl;

return 0;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: