-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClass.cpp
More file actions
35 lines (28 loc) · 768 Bytes
/
Copy pathClass.cpp
File metadata and controls
35 lines (28 loc) · 768 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
#include<iostream>
using namespace std;
class Complex{ //private by default //data security
//data members
int Real;
int Img;
//member functions
public: //made public manually
void accept(){
cout<<"Enter Real part: ";
cin>>Real;
cout<<"Enter imaginary part: ";
cin>>Img;
}
void disp(){
cout<<"Real part: "<<Real<<endl;
cout<<"Imaginary part: "<<Img<<"\n\n";
}
}; //end of class scope
int main(){
Complex c1; //creating object/instance of class //instantiation
c1.accept();
c1.disp();
Complex c2;
c2.accept();
c2.disp();
return 0;
}