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