1. Technology

Definition of Encapsulation

By

Business men looking at computer
Cultura RM/Adrian Weinbrecht/Collection Mix: Subjects/Getty Images
Definition: In Object Oriented Programming, encapsulation is an attribute of object design. It means that all of the object's data is contained and hidden in the object and access to it restricted to members of that class.

Programming languages aren't quite so strict and allow differing levels of access to the object's data. The first three levels of access shown below are in both C++ and C#, with the last two in C#.

  • Public : All Objects can access it.
  • Protected : Access is limited to members of the same class or descendants.
  • Private : Access is limited to members of the same class.
  • Internal : Access is limited to the current assembly.
  • Protected Internal : Access is limited to the current assembly or types derived from the containing class.

Glossary:

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Examples:
For the best encapsulation, object data should almost always be restricted to private or protected.
Related Video
Create Bullet, Number, and Definition Lists in HTML
Install a PCI Card
  1. About.com
  2. Technology
  3. C / C++ / C#
  4. Glossary
  5. Encapsulation - Definition and Examples in C+

©2014 About.com. All rights reserved.