Private, Public and Protected

While we are on the topic of accessiblity modifiers, we note that inheritance now introduces a third face to the public/private dichotomy we discussed earlier. There are now three possibilities. A public feature is accessible to everybody. A private feature is accessible only within a class. A protected feature is accessible within a class and within child classes.

Note that this meaning of protected is the one adopted by most languages. Java is an exception. In Java protected means accessible within the same package.

[audio] [real] Text to accompany slidexx, in Chapter 8 of An Introduction to Object-Oriented Programming