编写复数类CComplex,实现整数与实数,复数与复数之间的加.减.乘等各种基本运算
来源:学生作业帮助网 编辑:作业帮 时间:2024/07/01 04:44:20
![编写复数类CComplex,实现整数与实数,复数与复数之间的加.减.乘等各种基本运算](/uploads/image/z/6130642-58-2.jpg?t=%E7%BC%96%E5%86%99%E5%A4%8D%E6%95%B0%E7%B1%BBCComplex%2C%E5%AE%9E%E7%8E%B0%E6%95%B4%E6%95%B0%E4%B8%8E%E5%AE%9E%E6%95%B0%2C%E5%A4%8D%E6%95%B0%E4%B8%8E%E5%A4%8D%E6%95%B0%E4%B9%8B%E9%97%B4%E7%9A%84%E5%8A%A0.%E5%87%8F.%E4%B9%98%E7%AD%89%E5%90%84%E7%A7%8D%E5%9F%BA%E6%9C%AC%E8%BF%90%E7%AE%97)
编写复数类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