#ifndef COMPLEX_H
#define COMPLEX_H
#include <iostream>
using namespace std;
class Complex {
public:
Complex(double r = 0.0, double i = 0.0) {re = r; im = i;}
Complex(const Complex& rhs) {re = rhs.re; im = rhs.im;}
~Complex(void) {}
double real(void) const {return re;}
double imag(void) const {return im;}
void imag(double i) {im = i;}
void real(double r) {re = r;}
Complex& operator=(const Complex& rhs) {
if (this == &rhs) return *this;
re = rhs.re; im = rhs.im;
return *this;
}
bool operator==(const Complex& rhs) {
return ((real()==rhs.real()) && (imag()==rhs.imag()));
}
const Complex operator+(const Complex& rhs) {
return Complex(re+rhs.re, im+rhs.im);
}
private:
double re, im;
};
ostream& operator<<(ostream& output, const Complex& rhs) {
return output << "(" << rhs.real() << "," << rhs.imag() << "i)";
}
#endif