Jump to content

Encapsulation (computer science)

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Kyle the bot (talk | contribs) at 14:46, 7 July 2008 (robot Adding: fr:Encapsulation des données). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Encapsulation is the grouping together of data and functionality. While the C language used structs to group data together, C++ adds the functionality component. This does the following:

  1. Allows a programmer to explicitly provide the interface to an object
  2. Allows hiding of implementation details
  3. Allows programmer to think in an object-oriented way

Encapsulation simplifies programming by modeling the world: the world consists of objects that do things. Thus programs become a collection of objects and how they act, instead of a set of instructions.