Click here to Skip to main content
12,998,483 members (128,026 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Why .Net support multilevel inheretence insted of multiple inheritance?
Posted 21-Oct-12 15:33pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

The statement is inaccurate and not true. There is no such thing as "multi-level inheritance", or, if you will, every inheritance is "multi-level".

And .NET actually supports multiple inheritance, but only for interfaces. More exactly, any interface can list any number of base interfaces; and any class can list only one base class (by default, this is System.Object and any number of interfaces in its inheritance list, and should implement all of listed interfaces. This is sometimes called "weak form of multiple inheritance".

So, why not "strong" multiple inheritance, as in C++? This is pretty hard to explain. In brief, such inheritance case difficult problems in both implementation, but especially in use.
In this article, you can read about "diamond problem":[^].

This is not the only problem.

Unfortunately, I don't know one comprehensive article on this difficult topic; also, opinions of people are somewhat contradictory.

[EDIT #1]

Perhaps I would personally prefer to have "stronger" multiple inheritance which I would use with great care, but I would prefer finer control than that available in C++. I'm familiar with the finer multiple inheritance schema invented by one researcher I know well, but I'm afraid it is not implemented anywhere. And I don't think I know the universal solution which would be acceptable for majority of people and would somehow protect from stupid or unsafe decisions. This is a very serious problem. Having only the weak-form multiple inheritance is a kind of stay-away-of-trouble approach at the expense of insufficient expressive power. This is actually one of the most difficult and fundamental problems of OOP methodology.


The problem lies in the nature of things and hardly can be mitigated with one silver-bullet approach. Try to read different material on the topic:[^].

Besides, if you gain considerable experience in design of complex models using both single and multiple inheritance, you will be able to feel the problem on your own skin. :-)

[EDIT #2]

Please also see this past discussion, including my answer: Why one class cannot extend more than one class in java.[^].

Milind_T 7-Dec-12 4:11am
Superb explanation!!
Thank you, Milind.
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Because of Diamond problem[^] .Net doesn't support multiple inheritance.
The biggest problem with multiple-inheritance is that it allows for ambiguity when the compiler needs to find the correct implementation of a virtual method."

As .net support Multiple Interface Inheritance.

Hope this helps :)
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Just read about the "Diamond" Problem with multiple inheritance[^], you will get your answer.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170622.1 | Last Updated 27 Nov 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100