### Encapsulation

Another key feature of object-oriented programming is encapsulation . Encapsulation means a class can hide the details of:

- The representation of its data members
- The implementation of the operations that can be performed on these data members

Application programs manipulate objects of a class using a clearly defined interface. As long as this interface does not change, you can change the implementation of a class without having to change the application programs that use the class. Encapsulation provides the following advantages:

- Users of a class do not have to deal with unnecessary implementation details.
- Programs are easier to debug and maintain.
- Permitted alterations are clearly specified.

In C++, encapsulation is accomplished by specifying the level of access for each member of a class. Both the data members and member functions of a class can be declared public, protected, or private depending on the kind of access required.

Note: C++ encapsulation is not a true security mechanism. It is possible to circumvent the class access controls that make encapsulation possible. The language is not designed to prevent such misuse.

Access