-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtut21.cpp
More file actions
34 lines (31 loc) · 748 Bytes
/
tut21.cpp
File metadata and controls
34 lines (31 loc) · 748 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
#include<iostream>
using namespace std;
class Employee
{
private:
int a, b, c;
public:
int d, e;
void setData(int a1, int b1, int c1); // Declaration
void getData(){
cout<<"The value of a is "<<a<<endl;
cout<<"The value of b is "<<b<<endl;
cout<<"The value of c is "<<c<<endl;
cout<<"The value of d is "<<d<<endl;
cout<<"The value of e is "<<e<<endl;
}
};
void Employee :: setData(int a1, int b1, int c1){
a = a1;
b = b1;
c = c1;
}
int main(){
Employee Ritik;
// harry.a = 134; -->This will throw error as a is private
Ritik.d = 34;
Ritik.e = 89;
Ritik.setData(1,2,4);
Ritik.getData();
return 0;
}