Ask Question

Among object-oriented languages, one feature that varies considerably is whether the language allows multiple inheritance. C+ + does but Ada does not. Java takes a middle ground approach of allowing multiple inheritance of interfaces but not classes. Using a C+ + example, illustrate some of the complexities that multiple inheritance introduces. How does C+ + deal with them? Why does Java's middle ground approach offer some of the benefits of multiple inheritance while avoids its problems.

+3
Answers (1)
  1. 19 August, 16:04
    0
    Multiple inheritance causes Diamond problem which happens when:

    Class A is parent of class B and C

    Now when class D will be inherited from both Class B and C it will have all the members of class A and B which if same will confuse the compiler to import which one?

    C+ + solves it by using virtual keyword with them and thus telling the compiler which one to inherit.

    Java has introduced the interface concept rather then allowing multiple inheritance.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Among object-oriented languages, one feature that varies considerably is whether the language allows multiple inheritance. C+ + does but ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers