使用C++实现的复数类计算:
//Coded by ZZ
//#define COMPLEX_H
#if !defined(COMPLEX_H)
#define COMPLEX_H
#endif
#include <iostream>
#include <iomanip>
class Complex
{
public:
double real;
double imag;
public:
Complex();
Complex(double _real,double _imag = 0.0):real(_real),imag(_imag){} //构造函数,初始化列表和默认参数
void SetReal(double _real); //更改实部的值
void SetImag(double _imag); //更改虚部的值
void SetVal(double _real,double _imag); //更改整个复数
double GetModule(); //获得模值
void Conj(); //设置共轭
void ej(double Value); //ej设置数值
void ej(double Value1,double Value2); //ej设置数值
double GetReal() const;