24 lines
522 B
C++
24 lines
522 B
C++
#include <iostream>
|
|
#include "Complex.h"
|
|
|
|
Complex::Complex() : real(0), imag(0) {
|
|
}
|
|
|
|
Complex::Complex(double r, double i): real(r), imag(i) {
|
|
}
|
|
|
|
void Complex::print() const {
|
|
std::cout << "(" << real << ", " << imag << "i)" << std::endl;
|
|
}
|
|
|
|
Complex Complex::plus(Complex& c) const {
|
|
//Complex Complex::plus(const Complex& c) const {
|
|
Complex temp(real+c.real, imag+c.imag);
|
|
//c.real=0;
|
|
return temp;
|
|
}
|
|
|
|
//void Complex::add(double d) const {
|
|
void Complex::add(double d) {
|
|
real+=d;
|
|
} |