W Pearce wrote:The big concept behind it is that you don't want your member variables being able to be manipulated outside of their own class. For example, if you have an int called height in a Bacon class, you don't want any code to be able to make an instance of that class and set height directly:
Instead, you want to have your instance variables wrapped in getter and setter methods, so you can perform validation on them when something is passing them a variable. So for the example above, we would do something like:
And these would be called from your code like this:
That's a good explanation... but I have something to ask....
with this explanation there doesn't seem to be any difference between "Encapsulation" and "Abstraction".
So far, I've been thinking that Encapsulation is all about just putting the things together... while...
Abstraction concerns the usability of the members....
so by that meaning.... the above thing is "abstraction"...
Please explain if I am wrong.... ???