forked from Annex5061/java-algorithms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLab4ComplexNum.cpp
81 lines (78 loc) · 1.42 KB
/
Lab4ComplexNum.cpp
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/* Implement a class complex which represent the complex number data type.Implement the following operations:
1)Default Constuctor (including a default constuctor which creates the complex number 0+0i)
2)Paramatrised Constuctor (3+5i)
3)Copy Constuctor : use this to display the same complex number as of part 2 */
#include <iostream>
using namespace std;
class complex
{
int real,imaginary;
public:
complex()
{
real=imaginary=0;
}
void display()
{
cout<<real<<"+"<<imaginary<<"i"<<endl;
}
};
int main()
{
complex c;
c.display();
return 0;
}
/*
#include <iostream>
using namespace std;
class complex
{
int real,imaginary;
public:
complex(int r,int i)
{
real=3;
imaginary=5;
}
void display()
{
cout<<real<<"+"<<imaginary<<"i"<<endl;
}
};
int main()
{
complex c(3,5);
c.display();
return 0;
} */
/*
#include <iostream>
using namespace std;
class complex
{
int real,imaginary;
public:
complex(int r,int i)
{
real=r;
imaginary=i;
}
complex(complex &c)
{
real=c.real;
imaginary=c.imaginary;
}
void display()
{
cout<<real<<"+"<<imaginary<<"i"<<endl;
}
};
int main()
{
complex c1(3,5);
complex c2(c1);
c1.display();
c2.display();
return 0;
} */