Can anyone suggest any real life example of Hybrid inheri开发者_如何学Gotance?
Hybrid Inheritance is a method where one or more types of inheritance are combined together. I use Multilevel inheritance + Single Inheritance almost at all time when I need to implement an interface.
struct ExtraBase { void some_func(); };
struct Base : public ExtraBase {};
struct Derived : public Base, public IUnknown {};
...
Derived x = new Derived;
x->AddRef();
x->some_func();
Here is an example where Derived
uses some_func
from ExtraBase
(multilevel inheritance) and Derived
uses AddRef
from IUnknown
which is inherited a single time. Surely it is not from a production code, but the idea is close to it.
精彩评论