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:
An example would be:
/// Thread body interface
class runnable
{
public:
virtual ~runnable() {}
virtual void run() =0;
};
/// Starts OS thread, calls p->run() in new thread
thread_id start_thread( runnable* p );
/// Has a private thread
class actor: private runnable, private noncopyable
{
private:
thread_id tid; /// private thread
public:
actor() { tid = start_thread( this ); } // here this IS-A runnable
// ...
virtual ~actor() { stop_thread( tid ); }
private:
virtual void run() { /* work */ }
};