1/*Get or Set are methods to Access Private Members
2for example */
3
4class Employee {
5 private:
6 // Private attribute
7 int salary;
8
9 public:
10 // Setter
11 void setSalary(int s) {
12 salary = s;
13 }
14 // Getter
15 int getSalary() {
16 return salary;
17 }
18};
19
20int main() {
21 Employee myObj;
22 myObj.setSalary(50000);
23 cout << myObj.getSalary();
24 return 0;
25}
26