0

=>> Why java does not support multiple inheritance but C++ support multiple inheritance while both are OOP language ?

I know that we can extends only one class but implement more than one class. WHY ??

2nd Aug 2018, 1:05 PM
Alpha Rays
Alpha Rays - avatar
3 Answers
+ 1
to reduce complexity because multiple inheritance results in the "deadly diamond problem" (google it if you haven't heard about it), and there's no globally accepted workaround to it, so they solved it by removing multiple inheritance completely.
2nd Aug 2018, 3:26 PM
hinanawi
hinanawi - avatar
0
I read about 'deadly diamond problem' and yes you are right but why C++ support it ? Why did c++ programmer not remove multiple inheritance like java ? Did interface remove the problem arises due to multiple inheritance?
4th Aug 2018, 1:31 PM
Alpha Rays
Alpha Rays - avatar
0
Aman Kumar well, the solution in c++ works, but it's kinda complicated and is different than in other languages which leads to some confusion and conflict especially for people that use multiple languages to make programs. as for interfaces, they kind of supplement for multiple inheritance, at least enough to compensate for things the average programmer would require multiple inheritance for, but not 100%.
4th Aug 2018, 1:37 PM
hinanawi
hinanawi - avatar