-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtut25.cpp
More file actions
69 lines (58 loc) · 1.17 KB
/
Copy pathtut25.cpp
File metadata and controls
69 lines (58 loc) · 1.17 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
62
63
64
65
66
67
68
69
// #include<bits/stdc++.h>
// using namespace std;
// class employee{
// int id;
// int salary;
// public:
// void setId(void){
// salary=122;
// cout<<"enter thee id of employee";
// cin>>id;
// }
// void getId(void){
// cout<<"the id of this employee is "<<id<<endl;
// }
// };
// int main(){
// // employee harry, lovish,rohan ,shruti;
// // harry.setId();
// // harry.getId();
// employee fb[4];
// for(int i=0;i<4;++i){
// fb[i].setId();
// fb[i].getId();
// }
// return 0;
// }
#include <bits/stdc++.h>
using namespace std;
class Complex
{
int a;
int b;
public:
void setdata(int v1, int v2)
{
a = v1;
b = v2;
}
void setDataBySum(Complex o1, Complex o2)
{
a = o1.a + o2.a;
b = o1.b + o2.b;
}
void printNumber(void){
cout<<"Your complex number is "<<a<<"+i"<<b<<endl;
}
};
int main()
{
Complex c1, c2, c3;
c1.setdata(1, 2);
c1.printNumber();
c2.setdata(3, 4);
c2.printNumber();
c3.setDataBySum(c1, c2);
c3.printNumber();
return 0;
}