It\'s easy to understand the virtual function in public inheritance. So what\'s the point for virtual function in private or protected inheritance?
For example:
Private inheritance is just an implementation technique, not an is-a relationship, as Scott Meyers explains in Effective C++:
class Timer {
public:
explicit Timer(int tickFrequency);
virtual void onTick() const; // automatically called for each tick
...
};
class Widget: private Timer {
private:
virtual void onTick() const; // look at Widget private data
...
};
Widget clients shouldn't be able to call onTick on a Widget, because that's not part of the conceptual Widget interface.