Beginners beware!
Usually in lessons on inheritance, we learn that when a class extends another, the former inherits all the members of the latter. This statement is only partly true (in fact it is misleading!). The complete truth is that private members are not inherited.
I wish to restate the principle: "The access modifier 'private' is not just an access modifier. It also means that the member who has this modifier will not be inherited."
Usually in lessons on inheritance, we learn that when a class extends another, the former inherits all the members of the latter. This statement is only partly true (in fact it is misleading!). The complete truth is that private members are not inherited.
I wish to restate the principle: "The access modifier 'private' is not just an access modifier. It also means that the member who has this modifier will not be inherited."
Comment