第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

這題太可怕了.... 一堆錯誤,完全不知道如何下手啊 TAT

這題太可怕了.... 一堆錯誤,完全不知道如何下手啊 TAT

C++
慕粉4444739 2016-12-15 21:04:19
?#include <iostream>using namespace std;class CComplex{public: CComplex() { real = 0.0;? imag = 0.0; } CComplex(float x, float y) { real = x; imag = y; } CComplex operator + (CComplex &obj1, CComplex &obj2) { CComplex obj3(obj1.real + obj2.real, obj1.imag + obj2.imag); return obj3; } CComplex &operator++(CComplex &obj) { obj.real += 1; obj.imag +=1; return obj; } void print() { cout<<real<<"+"<<imag<<"i"<<endl; }private: float real; float imag;};CComplex &operator--(CComplex &x){ x.real -= 1; x.imag -= 1; return x;}void main(){ CComplex obj1(2.1,3.2); CComplex obj2(3.6,2.5); cout<<"obj1="; obj1.print(); cout<<"obj2="; obj2.print(); CComplex obj3 = obj1 + obj2; cout<<"befor++, obj3="; obj3.print(); ++obj3; cout<<"after++, obj3="; obj3.print(); --obj3; cout<<"after--, obj3="; obj3.print(); CComplex obj4 = ++obj3; cout<<"obj4="; obj4.print();}全是錯誤 ?看得頭暈了不懂怎么改。。。。
查看完整描述

1 回答

已采納
?
冷凌川

TA貢獻(xiàn)2條經(jīng)驗(yàn) 獲得超1個贊

#include <iostream>

using namespace std;

class CComplex

{

public:

CComplex()

{

real = 0.0;?

imag = 0.0;

}

CComplex(double x, double y)

{

real = x;

imag = y;

}

CComplex operator +(CComplex obj1)

{

CComplex obj2;

obj2.real = this->real + obj1.real;

obj2.imag = this->imag + obj1.imag;

return obj2;

}

CComplex operator ++()

{

this->real += 1;

this->imag +=1;

return *this;

}


CComplex operator--()

{

real -=1;

imag -=1;

return *this;

}


void print()

{

cout<<real<<"+"<<imag<<"i"<<endl;

}

private:

double real;

double imag;


};


void main()

{

CComplex obj1(2.1,3.2);

CComplex obj2(3.6,2.5);

cout<<"obj1=";

obj1.print();

cout<<"obj2=";

obj2.print();

CComplex obj3 = obj1 + obj2;

cout<<"befor++, obj3=";

obj3.print();

++obj3;

cout<<"after++, obj3=";

obj3.print();

--obj3;

cout<<"after--, obj3=";

obj3.print();

CComplex obj4 = ++obj3;

cout<<"obj4=";

obj4.print();

}


查看完整回答
1 反對 回復(fù) 2016-12-19
  • 1 回答
  • 1 關(guān)注
  • 1572 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號