作业帮 > 数学 > 作业

编写复数类CComplex,实现整数与实数,复数与复数之间的加.减.乘等各种基本运算

来源:学生作业帮 编辑:作业帮 分类:数学作业 时间:2024/05/15 01:32:03
编写复数类CComplex,实现整数与实数,复数与复数之间的加.减.乘等各种基本运算
#include
#include
#include
class CComplex
{
public:
friend double real (const CComplex&);
friend double imag (const CComplex&);
friend CComplex operator + (const CComplex&,const CComplex&);
friend CComplex operator - (const CComplex&,const CComplex&);
friend CComplex operator * (const CComplex&,const CComplex&);
friend CComplex operator / (const CComplex&,const CComplex&);
friend bool operator == (const CComplex&,const CComplex&);
friend bool operator != (const CComplex&,const CComplex&);
friend CComplex polar (double,double);
friend istream& operator>> (istream&,CComplex&);
friend ostream& operato