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

📄 complextype.h

📁 C++编成数据结构与程序设计方法 D.S.Malk编著
💻 H
字号:
//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;

    void getComplex(double& real, double& imag) const; 
	  //Function to retrieve the complex number. 
      //Postcondition: real = realPart; imag = imaginaryPart;
  
    complexType(double real = 0, double imag = 0);  
      //Constructor
      //Initializes the complex number 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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -