An object is similar to a structure, with the addition of method pointers, member access control, and an implicit data member which locates instances of the class (i.e., objects of the class) in the class hierarchy (essential for runtime inheritance features).
Encapsulation prevents users from breaking the invariants of the class, which is useful because it allows the implementation of a class of objects to be changed for aspects not exposed in the interface without impact to user code.
The definitions of encapsulation focus on the grouping and packaging of related information (cohesion) rather than security issues.
Barbara Liskov and Jeannette Wing formulated the principle succinctly in a 1994 paper as follows: Subtype Requirement: Let
Most current object-oriented languages distinguish subtyping and subclassing, however some approaches to design do not.
For class-based languages, this restriction is essential in order to preserve unified view of the class to its users.
The users should not need to care whether one of the implementations of a method happens to cause changes that break the invariants of the class.
Such changes can be made by destroying the object and constructing another in its place.
Although Simula introduced the class abstraction, the canonical example of a class-based language is Smalltalk.