?? complex.h
字號(hào):
// Complex類的定義及實(shí)現(xiàn)都在頭文件complex.h中完成。
#include <iostream >
using namespace std;
class CComplex
{
private:
double real;
double image;
public:
CComplex() //不帶參數(shù)的構(gòu)造函數(shù),即缺省構(gòu)造函數(shù)
{
cout<<"不帶參數(shù)的構(gòu)造函數(shù),即缺省構(gòu)造函數(shù),"
<<"用來(lái)創(chuàng)建實(shí)部和虛部都是0,即0對(duì)象。"<<endl;
real = 0.0;
image = 0.0;
}
CComplex(double rv) //帶一個(gè)參數(shù)的構(gòu)造函數(shù)
{
cout<<"帶一個(gè)參數(shù)的構(gòu)造函數(shù),用來(lái)創(chuàng)建只有實(shí)部的實(shí)數(shù)。"<<endl;
real = rv;
image = 0.0;
}
CComplex(double rv,double iv) //帶兩個(gè)參數(shù)的構(gòu)造函數(shù)
{
cout<<"帶兩個(gè)參數(shù)的構(gòu)造函數(shù),用來(lái)創(chuàng)建既有實(shí)部"
<<"又有虛部的復(fù)數(shù)"<<endl;
real = rv;
image =iv;
}
void print() //打印輸出復(fù)數(shù)的實(shí)部和虛部
{
cout << "(" << real <<"+"<<image<< "i)"<<endl;
}
};
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -