some more content
This commit is contained in:
24
OOP/encapsulation/main.cpp
Normal file
24
OOP/encapsulation/main.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
class Employee {
|
||||
private:
|
||||
int salary;
|
||||
public:
|
||||
// Setter
|
||||
void setSalary(int s) {
|
||||
salary = s;
|
||||
}
|
||||
int getSalary() {
|
||||
return salary;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
int main() {
|
||||
Employee myObj;
|
||||
myObj.setSalary(123000);
|
||||
cout << myObj.getSalary();
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user