⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 minicomplex.h

📁 10个比较经典的C++程序。初学者就先多学习学习别人吧。
💻 H
字号:
#ifndef H_MiniComplex
#define H_MiniComplex
#include <iostream>
using namespace std;
class MiniComplex
{public:
	//重载流插入和提取运算符
	friend ostream& operator<<(ostream& osObject, const MiniComplex& complex)
	{	osObject<<"("<<complex.realPart<<"+ "<<complex.imagPart<<"i"<<")";
		return osObject;			
	}
	friend istream& operator>> (istream& isObject, MiniComplex& complex)
	{	char ch;
		isObject >>complex.realPart>>ch>>complex.imagPart>>ch;
		return isObject;			
	}
    MiniComplex(double real = 0, double imag = 0);  			//构造函数
    MiniComplex operator+(const MiniComplex& otherComplex) const; //重载运算符 +
    MiniComplex operator-(const MiniComplex& otherComplex) const; //重载运算符 +
    MiniComplex operator*(const MiniComplex& otherComplex) const; //重载运算符 *
    MiniComplex operator/(const MiniComplex& otherComplex) const; //重载运算符 *
    bool operator==(const MiniComplex& otherComplex) const;//重载运算符  ==
private:
    double realPart; //存储实部变量
    double imagPart; //存储虚部变量
};
#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -