Preferences

Protected = subclasses can call them.

Virtual = subclasses can override them.

So basically, any subclass can call the method, and that method may be overridden in any other subclass.


What is the issue with those overrides? They only affect that one path in the hierarchy of inheritance, no? Not a C++ user here, but I imagine it would be catastrophic, if an unrelated (not on path to root superclass) class could override a method and affect unrelated classes/objects.
> They only affect that one path in the hierarchy of inheritance, no?

Not necessarily. If you create a diamond (or a spiderweb :) inheritence pattern, the amount of places the method can be called and overriden grows fast.

This item has no comments currently.