爱问知识人 爱问教育 医院库

设计一个复数类,并实现二种(加法 乘法)运算方法?

首页

设计一个复数类,并实现二种(加法 乘法)运算方法?


        

提交回答
好评回答
  • 2009-09-05 20:02:41
      #include#includeclassCComplex{ (doubler=0,doublei=0);CComplex(CComplex&c);CComplexoperator+(CComplexa);CComplexoperator*(CComplexm);friendostream&operator<<(ostream&os,CComplexc);~CComplex(); };CComplex::CComplex(doubler,doublei){real=r;imag=i;}CComplex::CComplex(CComplex&c){real=c。
      real;imag=c。imag;}CComplexCComplex::operator+(CComplexa){CComplexretVal;retVal。real=real+a。real;retVal。imag=imag+a。imag;returnretVal;}CComplexCComplex::operator*(CComplexm){CComplexretVal;retVal。
      real=real*m。real-imag*m。imag;retVal。imag=real*m。imag+imag*m。real;returnretVal;}ostream&operator<<(ostream&os,CComplexc){os。
      unsetf(ios::showpos);os<  0,3。0),b(5。0,7。0);cout<<"a*b="<

    小***

    2009-09-05 20:02:41

类似问题

换一换

相关推荐

正在加载...
最新问答 推荐信息 热门专题 热点推荐
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200

热点检索

  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
返回
顶部
帮助 意见
反馈

确定举报此问题

举报原因(必选):