What exactly is Encapsulation?

On wikipedia: http://en.wikipedia.org/wiki/Encapsulation_(object-oriented_programming)

And in my book it says:

"The idea of an object containing the data implicit to its definition, together with the functions that operate on that data, is referred to as encapsulation."

However whenever I google it people tell me its data hiding...

So which definition is right?

Also found another link: http://c2.com/cgi/wiki?EncapsulationIsNotInformationHiding
Last edited on
Data Hiding is part of encapsulation. Another part of Encapsulation is not having dependencies - for instance, the Enemy class should not have to know that the Player class even exists. If the Enemy class has to know that the Player class exists, then it's not properly encapsulated and you have ppor class design.
Last edited on
Ok, so data hiding is part of Encapsulation? So basically Encapsulation is both definitions?

Also I dont quite understand the second part.
Homework is a part of school, but school also has exams to study for.
Data hiding is a part of Encapsulation, but Encapsulation also requires little to no coupling.

Look up 'coupling' in terms of object oriented programming.
Alright I shall xD
Topic archived. No new replies allowed.