Quote:
"Encapsulation is the process of combining data and functions into a single unit called class "
This is a very limited view of encapsulation, from what I've been taught.

Encapsulation can be broken in some languages. Consider the use of an Abstract Data Type in C, for example. The programmer/client shouldn't have to worry about how something is done, just that it gets done. You might implement linked lists and provide a "lLists.h" with headers to a whole bunch of functions you've written to manipulate your linked lists. The client should never open "lLists.c", nor be aware of how they are implemented, instead interacting with them only through the functions whose prototypes are provided in "lLists.h". This way, the implementation can be changed (to be more memory efficient, speed efficient, remove bugs, etc) without affecting the client in the slightest. When you manipulate its values directly, you "break encapsulation", and implementations of the same ADT are no longer necessarily interchangeable.

Object oriented programming languages like C++ and Java often provide means to enforce encapsulation (private), but encapsulation isn't restricted to OO languages.

Jibb


Formerly known as JulzMighty.
I made KarBOOM!