I have not checked to see if a thread exists already that talks about this, but here's my question: Why did they take out MI from Java? If it's possible in C++, then it's not impossible...
Joined: Feb 01, 2007
There never was MI in Java. The way you can implement Mi in java is by interfaces or a class A extending from class B and then extending Class c from A. MI can create lot of issues, even though it is there in C++ doesn't mean its a good thing. If you have to do MI which would mean that you need to really look at your design to see why you would need MI and how you can change that. In the past I was using MI and think it used to be good but later realized how problematic and painful it can get.
Joined: Oct 30, 2006
Originally posted by Harjit Singh: MI can create lot of issues, even though it is there in C++ doesn't mean its a good thing. - Harjit
That's true... However, just because it is usually bad doesn't mean it shouldn't be supported. If you use it the wrong way, it's your fault, but if you use it the right way, it can really help some programs. After all, you don't always have the source code, so you can't decide whether something is a class or an interface. An amphibian, for example, is a SeaCreature and a LandCreature.
author and iconoclast
The diamond problem is one of the most well-known issues that make multiple inheritance somewhat ambiguous. In C++, this is solved by introducing virtual inheritance.
You don't have the diamond problem with inheriting multiple interfaces, because you're not inheriting implementation or data from superclasses that way.
My opinion: You don't need multiple inheritance. It's a good thing that the designers of the Java language were conservative. If they would have put in every conceivable feature "just because it's possible" then Java would have been vastly more complex and it would not have been so successful. The more complex a progamming language is, the harder it is to write and maintain progams in it and the less popular it will be. [ February 16, 2007: Message edited by: Jesper Young ]