consolidate all repos to one for archive
This commit is contained in:
69
semester_2/programiranje_2/primeri/Example22/Complex.cpp
Normal file
69
semester_2/programiranje_2/primeri/Example22/Complex.cpp
Normal file
@@ -0,0 +1,69 @@
|
||||
#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;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
Reference in New Issue
Block a user