第九周實驗報告(任務1)

2021-06-05 23:42:33 字數 947 閱讀 7913

源程式:

#includeusing namespace std;

class complex

complex(double r,double i)

friend istream &operator>>(istream &input,complex &c2);

friend ostream &operator<

friend complex operator+(double d,complex &c2);

friend complex operator-(double d,complex &c2);

friend complex operator*(double d,complex &c2);

friend complex operator/(double d,complex &c2);

friend complex operator+(complex &c2,double d);

friend complex operator-(complex &c2,double d);

friend complex operator*(complex &c2,double d);

friend complex operator/(complex &c2,double d);

void display();

private:

double real;

double imag;

};//下面定義成員函式

istream &operator>>(istream &input,complex &c2)

ostream &operator<

執行結果:

知識積累: 綜合到任務3

第九周實驗報告1

程式頭部注釋開始 程式的版權和版本宣告部分 檔名稱 流運算子過載運算子 complex類 作 者 於宸 完成日期 2012 年 4 月 15 日 版 本 號 1.053 對任務及求解方法的描述部分 輸入描述 複數 問題描述 複數流運算子過載 程式輸出 程式頭部的注釋結束 includeusing n...

第九周實驗報告 任務五

源程式 include using namespace std class cequation cequation cequation double aa,double bb istream operator istream in,cequation e ostream operator ostre...

第九周實驗報告任務二

程式頭部注釋開始 程式的版權和版本宣告部分 作 者 郭巖巖 完成日期 2012 年4月 17日 版 本 號 vc.1 對任務及求解方法的描述部分 輸入描述 問題描述 程式輸出 程式頭部的注釋結束 include using namespace std include using namespace ...