-
Notifications
You must be signed in to change notification settings - Fork 0
/
complex.h
40 lines (34 loc) · 1.1 KB
/
complex.h
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
#ifndef COMPLEX_H
#define COMPLEX_H
#include <iostream>
#include <iomanip>
using namespace std;
class Complex {
//overload stream insertion and extraction operators
friend std::ostream &operator<<(std::ostream&, const Complex&);
friend std::istream &operator>>(std::istream&, Complex&);
friend Complex operator+(double lhs, const Complex & rhs); //double+complex
friend Complex operator+(Complex lhs, const Complex & rhs); //complex*complex
friend Complex operator*(double lhs, const Complex & rhs); //double*complex
friend Complex operator*(Complex lhs, const Complex & rhs); // complex*complex
public:
//public member functions
Complex(double x, double);
Complex();
double getReal();
double getImag();
void setReal(double);
void setImag(double);
void printSign();
Complex operator+(Complex & c); //complex+complex
Complex operator+(double & d); // complex+double
Complex operator*(Complex & c); //complex*complex
Complex operator*(double & d); //complex*double
private:
//data members of class Complex
double realPart;
double imagPart;
char sign;
char compSign;
};
#endif