-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathComplex.cpp
More file actions
50 lines (46 loc) · 866 Bytes
/
Copy pathComplex.cpp
File metadata and controls
50 lines (46 loc) · 866 Bytes
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
// 20190324_ex4.cpp: ¥Dn±M®×ÀÉ¡C
#include "stdafx.h"
#include <iostream>
using namespace std;
class CCOMPLEX{
private:
double real;
double image;
public:
CCOMPLEX();
CCOMPLEX(double, double);
CCOMPLEX add(CCOMPLEX &);
CCOMPLEX sub(CCOMPLEX &);
CCOMPLEX mul(CCOMPLEX &);
CCOMPLEX div(CCOMPLEX &);
void show() const;
};
int main()
{
CCOMPLEX a(2.0,3.0), b(4.0,5.0);
a.add(b).show();
//b.sub(a).show();
system("pause");
return 0;
}
CCOMPLEX::CCOMPLEX(){
real = 0.0;
image = 0.0;
}
CCOMPLEX::CCOMPLEX(double m, double n){
real = m;
image = n;
}
CCOMPLEX CCOMPLEX::add(CCOMPLEX &b){
CCOMPLEX temp;
temp.real = this->real + b.real;
temp.image = this->image +b.image;
return temp;
}
CCOMPLEX CCOMPLEX::sub(CCOMPLEX &b){
CCOMPLEX temp;
return temp;
}
void CCOMPLEX::show() const{
cout << this->real << '+' << this->image << 'i' << endl;
}