If you haven’t read my earlier articles on Object Oriented Programming in C (Objects and Polymorphism) I suggest that you go back and read these first. It isn’t necessary to understand these concepts in order to understand Encapsulation – but it might help give you some background into what I am attempting to achieve here.
To recap, Encapsulation is a means of preventing access to internal object data, ensuring that the data can only be accessed and modified via methods. That’s not to say the internal object data can never be manipulated directly – but one has the option to decide how best the data should be accessed. In explicitly OOP languages this is often achieved through the use of the ‘private’, ‘public’ and ‘protected’ keywords. Continue reading “Object Oriented C – Encapsulation”