Skip to main content

Posts

Showing posts with the label Data hiding

How data hiding is accomplished?

 Data hiding is accomplished in object-oriented programming (OOP) through the use of access specifiers, which determine the visibility and accessibility of class members. In C++, access specifiers are implemented using the keywords "public," "private," and "protected." "Public" members are accessible by any code that has a reference to the object. These members can be accessed from outside the class, and they define the interface through which the object can be manipulated. "Private" members are accessible only by the class itself and its friend functions. These members cannot be accessed from outside the class and are hidden from the user. "Protected" members are accessible by the class and its derived classes. These members cannot be accessed from outside the class hierarchy and are used to implement inheritance. By using the "private" access specifier, the data is effectively hidden from the user, making it inacce...