哪里出错了。。。大侠帮帮忙啊
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;
}
#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;
}
相关文章推荐
- 我想知道哪里出错了---关于以数组为参数的函数
- 那位大侠帮帮忙呀!!!!
- 在写javascript时找不到哪里出错的可能原因
- 哪位大侠能帮我解决一下,为什么二级关联能用,三级关联老是出错,谢谢了.
- struts2 配置tomcat的是时候出错了高手帮帮忙啊
- java连接数据库出错啊!请大家帮帮忙啊!!!
- eclipse 项目报错 但没有提示哪里出错
- 关于序列化的问题!!!哪位大侠帮帮忙???
- 设计一个表格控件,总在这个过程出错,不知道原因出在哪里,高手帮我找找原因?
- 哪位大侠帮帮忙啊(java邻接表的初始化)
- 并查集不知道哪里出错了
- 想在编辑框返回一个数值,但是不知哪里出错
- Project Euler 80 不知哪里出错,请牛人帮忙.
- 谁能告诉我哪里出错了,JCL
- javascript调试过程中找不到哪里出错的可能原因
- 两个文本框日期比较大小时出错,请看一下错在哪里,谢了!
- MFC程序中,只要加上#include <vector>,程序就报错(在其它位置),去掉这行没问题?不明白哪里出错了?
- 为什么卸载了VC6.0之后再安装就不行了啊,大侠帮帮忙啊
- 各位大侠帮帮忙!
- 请求大虾们救我,解决下面的代码!我不知道哪里出错了!!!