Click to See Complete Forum and Search --> : Inheritance
aamirshan
May 28th, 2002, 12:04 AM
Hi,
I only want ask that why there is no multi inheritance in java.
Any body can tell me its reason.
thanks in advance.
Suzi
May 28th, 2002, 10:28 AM
I think is because it can cause trouble...
If a class inherit from two classes that both have a method with the name, which one will then be used?
Instead Java use interfaces that provides some of the abilities that multiple inheritance has. A Java class can implement many different interfaces.
/Suzi
proxima centaur
May 28th, 2002, 10:30 AM
Multiple inheritance is not "pure" Object Oriented.
Some might argue you should never use multiple inheritance even if the language allows it. Multiple inheritance can cause vtable resolving ambiguities and is harder to debug.
I personally think this was added as a feature in C++ because it can be useful to patch a design that didn't take something into account. You can hack your way through with multiple inheritance.
But I firmly believe you can always rearrange things to make your design with single inheritance.
codeguru.com
Copyright WebMediaBrands Inc., All Rights Reserved.