Skip to content

Latest commit

 

History

History
5 lines (4 loc) · 540 Bytes

7.18.md

File metadata and controls

5 lines (4 loc) · 540 Bytes

Encapsulation enforces the separation between interface and implementation in a class via access specifiers. Encapsulation provides some advantages:

  • A class that is encapsulated hides its implementation to the user of the class, thus the user need not know how the class works, they can regard the class as a type (like a built-in type) instead.
  • User code cannot inadvertently corrupt the state of an encapsulated object.
  • The implementation of an encapsulated class can change over time without requiring changes in user code.