Data Encapsulation :

Data Encapsulation is wrapping up of data into a single unit.

  • It is also sometimes called Data Hiding.
  • It is done at implementation level.
  • The user can perform only a restricted set of operations in the hidden member of the class.
  • Classes are used in C++ to implement it.
  • They encapsulate all the essential properties of the object that are to be created
  • The advantage of data encapsulation comes when the implementation of the class changes but the interface remains the same.
  • The data and function are bundled inside the class that take total control of maintenance and thus human errors are reduced.
  • Improves the understandability of the application.
  • It increases security.

Following program illustrates use of classes for encapsulation :


Leave a Reply

Your email address will not be published. Required fields are marked *