Day 5 code
This commit is contained in:
parent
95f09146de
commit
75120f935f
3 changed files with 57 additions and 0 deletions
20
ComplexNumber.cpp
Normal file
20
ComplexNumber.cpp
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
//
|
||||
// Created by benmo on 9/30/2020.
|
||||
//
|
||||
|
||||
#include "ComplexNumber.h"
|
||||
|
||||
ComplexNumber::ComplexNumber(int a, int b) {
|
||||
this->a = a;
|
||||
this->b = b;
|
||||
}
|
||||
|
||||
ostream& operator<<(ostream& os, const ComplexNumber& cn) {
|
||||
os << cn.a << "+" << cn.b << "i";
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
ComplexNumber operator+(const ComplexNumber& cna, const ComplexNumber& cnb) {
|
||||
return ComplexNumber(cna.a + cnb.a, cna.b + cnb.b);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue