-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathComplexNumber.h
More file actions
61 lines (50 loc) · 1.28 KB
/
ComplexNumber.h
File metadata and controls
61 lines (50 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#ifndef _COMPLEXNUMBER_
#define _COMPLEXNUMBER_
#include "numberbase.h"
#include <iostream>
/*
Author: Gene Silva
Class: CSC220 Summer 2015
Project 2: Complex Number class
*/
// ComplexNumber - base class
class ComplexNumber:public NumberBase
{
private:
float real;
float imag;
public:
//constructor
ComplexNumber(float x = 0, float y = 0): NumberBase("an A for Gene Silva(Complex Numbers)")
{
real = x;
imag = y;
}
// Accessor/ Mutator
float getreal() const
{
return real;
};
void setreal(float x)
{
real = x;
};
int getimag() const
{
return imag;
};
void setimag(float y)
{
imag = y;
}
// Overloading Operators
ComplexNumber operator+(const ComplexNumber &that);
ComplexNumber operator-(const ComplexNumber &that);
ComplexNumber operator*(const ComplexNumber &that);
ComplexNumber operator/(const ComplexNumber &that);
friend std::ostream& operator<<(std::ostream &strm, const ComplexNumber &cn);
ComplexNumber operator*(float f);
void print();
void demo();
};
#endif