70 lines
1.4 KiB
C++

#include <iostream>
#include "Complex.h"
Complex::Complex() : real(0), imag(0) {
}
Complex::Complex(double r, double i): real(r), imag(i) {
}
Complex::~Complex() {
}
void Complex::print() const {
std::cout << "(" << real << ", " << imag << "i)" << std::endl;
}
Complex Complex::plus(const Complex& snd) const {
Complex temp(real+snd.real, imag+snd.imag);
return temp;
}
Complex Complex::operator+(const Complex& snd) const {
Complex temp(real+snd.real, imag+snd.imag);
return temp;
}
/*
bool Complex::operator==(const Complex& snd) const {
if (this == &snd)
return true;
if ((this->real == snd.real) && (this->imag == snd.imag))
return true;
return false;
}
*/
/*
void Complex::operator=(const Complex& right) {
this->real = right.real;
this->imag = right.imag;
}
*/
/*
Complex& Complex::operator=(const Complex& right) {
this->real = right.real;
this->imag = right.imag;
return *this;
}
*/
/*
//prefix operator++
Complex& Complex::operator++() {
this->real++;
return *this;
}
//postfix operator++
Complex& Complex::operator++(int dummy) {
this->real += 10;
return *this;
}
*/
/*
// global function - a friend of class Complex
Complex operator+(double d, const Complex& snd) {
Complex temp(d+snd.real, 0+snd.imag);
return temp;
}
*/