complextype.h
来自「data+structures+using+c的源码」· C头文件 代码 · 共 43 行
H
43 行
//Specification file complexType.h
#ifndef H_complexNumber
#define H_complexNumber
#include <iostream>
using namespace std;
class complexType
{
//Overload the stream insertion and extraction operators
friend ostream& operator<< (ostream&, const complexType&);
friend istream& operator>> (istream&, complexType&);
public:
void setComplex(const double& real, const double& imag);
//Function to set the complex numbers according to
//the parameters.
//Postcondition: realPart = real; imaginaryPart = imag
complexType(double real = 0, double imag = 0);
//constructor
//Initializes the complex numbers according to
//the parameters.
//Postcondition: realPart = real; imaginaryPart = imag
complexType operator+(const complexType& otherComplex) const;
//Overload the operator +
complexType operator*(const complexType& otherComplex) const;
//Overload the operator *
bool operator==(const complexType& otherComplex) const;
//Overload the operator ==
private:
double realPart; //variable to store the real part
double imaginaryPart; //variable to store the imaginary part
};
#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?