?? complex.cpp
字號:
#include <iostream >
using namespace std;
class CComplex
{
private:
double real;
double image;
public:
CComplex() //不帶參數的構造函數,即缺省構造函數
{
real = 0.0;
image = 0.0;
}
CComplex(double rv) //帶一個參數的構造函數
{
real = rv;
image = 0.0;
}
CComplex(double rv,double iv) //帶兩個參數的構造函數
{
real = rv;
image = iv;
}
void print() //打印輸出復數的實部和虛部
{
cout << "(" << real <<"+"<<image<< "i)"<<endl;
}
};
//下面的main函數為測試使用
int main( )
{
CComplex z1,z2(2),z3(2,3);
z1.print( );
z2.print( );
z3.print( );
return 0;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -