From 523f2fc0b6acff214a03d08f96f86926559d22fe Mon Sep 17 00:00:00 2001 From: Micke Nordin Date: Sat, 18 Apr 2020 10:37:53 +0200 Subject: [PATCH] Add subtraction --- cnumber.hpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cnumber.hpp b/cnumber.hpp index 81b0e29..09e7e79 100644 --- a/cnumber.hpp +++ b/cnumber.hpp @@ -28,7 +28,11 @@ class cnumber { // Operators cnumber operator+(const cnumber &that) { - cnumber z(that.r + this->r, that.i + this->i); + cnumber z(this->r + that.r, this->i + that.i); + return z; + } + cnumber operator-(const cnumber &that) { + cnumber z(this->r - that.r, this->i - that.i); return z; } cnumber operator*(const cnumber &that) {