- Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path19)OOPS_AccessSpecifiers.cpp
43 lines (34 loc) · 980 Bytes
/
19)OOPS_AccessSpecifiers.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
#include<iostream>
usingnamespacestd;
classEmployee// Class
{
public:
string name;
int salary;
Employee(string n, int s, int sp) // Constructor
{
this->name = n;
this->salary = s;
this->secretPassword = sp;
}
voidprintDetails() // Method
{
cout << "ame of our first employee is " << this->name << endl;
cout << "Salary of our first employee is " << this->salary << endl;
}
voidgetsecretPassword() // Getter and Setter Method
{
cout << "Secret Password is " << this->secretPassword << endl;
}
private:
int secretPassword;
};
intmain()
{
Employee employee1("Mooazam", 100000, 123); // Constructor Object
employee1.printDetails();
// cout << "Secret Password is " << employee1.secretPassword << endl;
// Above line can not run because secretPassword is private.
employee1.getsecretPassword();
return0;
}