complex.h
unknown
c_cpp
4 years ago
1.6 kB
8
Indexable
// complex.h
#ifndef COMPLEX_H
#define COMPLEX_H
#include <string>
#include <ostream>
// class Complex number
class Complex {
    private:
        // real part
        float m_real;
        // imaginary part
        float m_imag;
    public:
        Complex(float real, float imag);
        // getters for m_real and m_imag
        float getReal();
        float getImag();
        // checks if m_imag == 0
        bool isReal();
        // checks if m_real == 0
        bool isImag();
        // check is *this Complex number is equal to the argument complex number 
        bool equals(Complex); 
        // return Complex number that is a product of sum of *this and argument
        Complex add(Complex);
        // return Complex number that is a product of difference of *this and argument
        Complex subtract(Complex);
        // return Complex number that is a product of multiplication of *this and argument
        Complex multiply(Complex);
        // return Complex number that is a product of division of *this and argument
        Complex divide(Complex);
        // cout *this, ex.: 4+7i
        void print();
        // return string of this, ex.: 4+7i
        std::string toString();
        Complex operator+(const Complex &right);
        Complex operator-(const Complex &right);
        Complex operator*(const Complex &right);
        Complex operator/(const Complex &right);
        bool operator==(const Complex &right);
        friend std::ostream& operator<<(std::ostream &out, const Complex& c);
};
std::ostream& operator<<(std::ostream &out, const Complex& c);
#endif // COMPLEX_HEditor is loading...