-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path21_OOPs.cpp
43 lines (32 loc) · 872 Bytes
/
21_OOPs.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
// Classes, Public and Private access modifiers
#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 Raj;
// Raj.a = 2122; ---> Gives Error as a is private, Therefore cannot be accessed.
Raj.d = 123;
Raj.e = 34;
Raj.setData(1, 2, 4);
Raj.getData();
return 0;
}