Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When might multiple inheritance be the only reasonable solution? [closed]

To be clear, I'm not asking if/why multiple inheritance is good or bad. I've heard a lot of arguments from both sides of that debate.

I'm wondering if there is any kind of design problem or scenario in C++ in which multiple inheritance is either the only way to accomplish something, or at least is the most optimal way over all other alternatives to the point that it wouldn't make sense to consider anything else.

Obviously, this question doesn't apply to languages that don't support multiple inheritance.

like image 730
Jeff L Avatar asked Jul 07 '09 18:07

Jeff L


2 Answers

You can't do policy-based design without multiple inheritance. So if policy-based design is the most elegant way to solve your problem, than that means you need multiple inheritance to solve your problem, over all other options.

Multiple-inheritance can be very useful if it's not misused (like everything, in any language).

like image 79
GManNickG Avatar answered Sep 28 '22 03:09

GManNickG


There is a situation in which you would inherit from a class and maybe implement one or two interfaces in Java. This is something you would resolve with multiple inheritance in c++ I think.

like image 42
Janusz Avatar answered Sep 28 '22 01:09

Janusz