永发信息网

c++改错题 #include <iostream.h> #include <math.h> class complex { double real; do

答案:1  悬赏:30  手机版
解决时间 2021-03-28 03:12
  • 提问者网友:了了无期
  • 2021-03-27 20:59
c++改错题 #include <iostream.h> #include <math.h> class complex { double real; do
最佳答案
  • 五星知识达人网友:何以畏孤独
  • 2021-03-27 21:13
#include 
#include 
class complex
{
double real;
double imag;
public:
    complex(double r=0.0,double i=0.0):real(r),imag(i){};
    void show()
    {
    cout<<"REAL"<<(imag>=0?'+':'-')<    }
    friend complex&operator +=(complex& c1,const complex& c2);
};
complex&operator +=(complex& c1,const complex& c2){
        c1.real+=c2.real;
        c1.imag+=c2.imag;
        return c1;
    }
int main()
{
complex c(3,5);
c+=complex(2,3);
c.show();
}
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯