Can anyone suggest any real life example of Hybrid inheritance?
A:
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.
Kirill V. Lyadvinsky
2010-07-20 12:31:36
Should `Base` derive from `ExtraBase` in the code?
David Rodríguez - dribeas
2010-07-20 13:34:57
Yes, fixed that.
Kirill V. Lyadvinsky
2010-07-20 13:55:01
Can you give me some real life example where Hybrid inheritance is used?
Mayur
2010-07-26 03:43:44
You have a class with multilevel inheritance and you need to implement some sort of callback interface - this is from real life.
Kirill V. Lyadvinsky
2010-07-26 04:28:20