编写复数类CComplex,实现整数与实数,复数与复数之间的加.减.乘等各种基本运算
来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/09 04:39:31
编写复数类CComplex,实现整数与实数,复数与复数之间的加.减.乘等各种基本运算
编写复数类CComplex,实现整数与实数,复数与复数之间的加.减.乘等各种基本运算
编写复数类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& operator