virtual function in private or protected inheritance

c++

Solution

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.

Problem

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: ``` class Base { public: virtual void f() { cout<<"Base::f()"<<endl;} }; class Derived: private Base { public: void f() { cout<<"Derived::f()"<<endl;} }; ``` Is this still called overriding? What's the use of this case? What's the relationship of these two f()? Thanks!

Original source