-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtut21.cpp
More file actions
49 lines (41 loc) · 1.12 KB
/
tut21.cpp
File metadata and controls
49 lines (41 loc) · 1.12 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
#include <iostream>
using namespace std;
// structure (struct) is not usefull for data hiding
// Data hiding is possible only by using OOP
// ************ Classes & Private & Public ************
class Employee
{
private:
int a, b, c;
// void setData(int a1, int b1, int c1); // Declaration for searching further
public:
int d, e;
void setData(int a1, int b1, int c1); // Declaration for searching further
void getData()
{
// Can implement here it self
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;
cout << "This is employee setData" << endl;
}
int main()
{
Employee shubh;
// shubh.a = 23 --> This will throw error as it is private
shubh.d = 24;
shubh.e = 32;
cout << "Setting employee data" << endl;
shubh.setData(1, 2, 3);
shubh.getData();
return 0;
}