+ 15

Why does C++ support multiple Inheritance of Classes

In Java, multiple inheritance of classes is not allowed as two classes can have different implementations of the same method, but why is multiple inheritance possible in C++, can it not cause problems?

16th Dec 2017, 9:58 AM
David Akhihiero
David Akhihiero - avatar
2 odpowiedzi
+ 6
You can have the same result in Java with default methods in interfaces. So really there isn't a difference anymore. In both cases the code simply won't compile, if you do not explicitly overwrite the conflicted method. Another solution is serialization in Scala. In Scala the order matters. class X extends A with B gets B's method in case of conflict. class X extends B with A gets A's method So there are various solutions.
16th Dec 2017, 10:07 AM
1of3
1of3 - avatar