In OO, encapsulation is the idea that an object's inner workings do not need to be known, only the way to interface with the object needs to be known. That is, how and what information to give to the object and get from the object. A black box.

Several features of C++ encourage encapsulation. There is, of course, the foundation of C++ OO, the class, with access specifiers that limit the rights other functions have to access the contents of the class. Generally speaking, good programming practice is that all data members should be protected or private. Even derived classes should avoid accessing the base class' contents directly. The Windows APIs are a good example of this; most windows programmers have no knowledge of the OS

Encapsulation is the process of combining data (attributes) and functions (behavior in the form of code) into an object. The data and the functions are closely coupled within an object. Instead of every programmer being able to access the data within a structure using her own way, programmers have to use the code connected with that data. This promotes code reuse and standarized methods of working with the data.

Para; Robin Burk

En*cap`su*la"tion (?), n. Physiol.

The act of inclosing in a capsule; the growth of a membrane around (any part) so as to inclose it in a capsule.

 

© Webster 1913.

Log in or register to write something here or to contact authors.