How Encapsulation is different from data hiding
Can anybody tell me How Encapsulation is different from data hiding ?
I have gone through the book and google search but I do not understand how Encapsulation is different from data hiding
Encapsulation means to protect sensitive informationin an object by making members protected or private in a class
Data hiding means to make sure that sensitive data is hidden from user
Code:
class Employee {
private:
// Private member
int salary;
public:
// Setter
void setSalary(int s) {
salary = s;
}
// Getter
int getSalary() {
return salary;
}
};