1. Home
  2. Computing & Technology
  3. C / C++ / C#

Definition of Encapsulation

By David Bolton, About.com

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.
Explore C / C++ / C#
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. C / C++ / C#

©2009 About.com, a part of The New York Times Company.

All rights reserved.