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

📄 complex.h

📁 ThinkingC++中文版
💻 H
字号:
#include "iostream.h"


class complex{
private:   
	double rpart;
    double ipart;
public:     
	complex() //complex a;
	{
		rpart = ipart = 0.0;
	}
	complex(double rp,double ip) //complex b(1.1,2.2);
	{  
		rpart=rp;   
		ipart=ip; 
	}			  
	
	complex(double d)//complex c(3.3);
	{
		rpart = d;
		ipart=0.0;
	}

	const complex add(const complex& com);
	const complex operator+(const complex& com); //成员函数版
//  friend const complex operator+(const complex& x, const complex& y);//友员函数版
	friend const complex operator*( const complex& x, const complex& y);

	complex operator-();//单目减  ,不能写成const complex operator-()  因为:-a+b
	void print();

	friend ostream& operator<<(ostream& os, const complex& com);
    friend istream& operator>>(istream& is, complex& com);

};

⌨️ 快捷键说明

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