-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathComplex.hpp
28 lines (26 loc) · 1.19 KB
/
Complex.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#pragma once
#include <iostream>
class Complex
{
private:
double Re;
double Im;
public:
Complex(float Re, float Im) : Re(Re), Im(Im) {}
Complex() : Re(0), Im(0) {}
public:
double GetRe() const { return this->Re; }
double GetIm() const { return this->Im; }
void Print() const { std::cout << this->Re << " + " << "i * " << this->Im; }
bool operator == (const Complex& another) { return (this->Re == another.GetRe() && this->Im == another.GetIm()); }
bool operator != (const Complex& another) { return (this->Re != another.GetRe() || this->Im != another.GetIm()); }
bool operator < (const Complex& another) { return ((this->GetRe())*(this->GetRe()) + (this->GetIm()) * (this->GetIm()) < another.GetRe() * another.GetRe() + another.GetIm()* another.GetIm()); }
bool operator > (const Complex& another) { return ((this->GetRe())*(this->GetRe()) + (this->GetIm()) * (this->GetIm()) > another.GetRe() * another.GetRe() + another.GetIm()* another.GetIm()); }
Complex& operator = (const Complex* another)
{
if(this == another) return *this;
this->Re = another->GetRe();
this->Im = another->GetIm();
return *this;
}
};