Here's the canonical example I used to quote for multiple inheritance: "Implementing the design pattern observer".
You basically want to add public methods addEventListener(), removeEventListener() and a protected fireEvent() method. In Java you have no problem inheriting the interface for these methods. However you want to manually re-implement the damn implementation in each class that vends interface. I can't remember how many times I wrote these...
In C++ with multiple inheritance you can inherit both the interface and implementation, and you're done. It is one step further than Java interfaces.
These days, I don't use that so much and I would not miss multiple inheritance. I prefer to implement the design pattern observer through signals (boost::signal in C++, custom classes in JavaScript/TypeScript). C# delegates provide a good solution for this problem too.
I have not touched Java since 1.4, so maybe there is a more elegant way to solve this now...
You basically want to add public methods addEventListener(), removeEventListener() and a protected fireEvent() method. In Java you have no problem inheriting the interface for these methods. However you want to manually re-implement the damn implementation in each class that vends interface. I can't remember how many times I wrote these...
Why? Just use composition and delegate addEventListener() and removeEventListener() to the member implementing the logic?
That's a good idea. And as that's a common pattern, you could allow the programmer to specify that the compiler should automatically implement this delegation. You could call this feature something like, I don't know, "multiple inheritance".
Then you don't understand composition. I can pass the actual implementation in the constructor or via dependency injection. With multiple inheritance, your class is restricted to one implementation. Moreover, it couples the class with the internals of observables, rather than using simple interfaces, which composition provides.
IMHO multiple inheritance is a bad solution to this problem. I would be more inclined to use a DI pattern and inject an event manager wherever it's needed.
Even when multiple inheritance is genuinely useful, it still feels dirty to me. PHP actually has a nice feature called traits, which is essentially compiler-assisted copy & paste. It means you can re-use code without duplication and without the confusion that multiple inheritance can bring.
You basically want to add public methods addEventListener(), removeEventListener() and a protected fireEvent() method. In Java you have no problem inheriting the interface for these methods. However you want to manually re-implement the damn implementation in each class that vends interface. I can't remember how many times I wrote these...
In C++ with multiple inheritance you can inherit both the interface and implementation, and you're done. It is one step further than Java interfaces.
These days, I don't use that so much and I would not miss multiple inheritance. I prefer to implement the design pattern observer through signals (boost::signal in C++, custom classes in JavaScript/TypeScript). C# delegates provide a good solution for this problem too.
I have not touched Java since 1.4, so maybe there is a more elegant way to solve this now...