Communiquez avec les autres et partagez vos connaissances professionnelles

Inscrivez-vous ou connectez-vous pour rejoindre votre communauté professionnelle.

Suivre

Why .net does not multiple inheritance?

user-image
Question ajoutée par AJAM KHAJA SHAIK , process developer , Genpact - India
Date de publication: 2013/10/25
Mohammed Sadique
par Mohammed Sadique , Senior Software Analyst , Alyousuf Exchange and Money Transfers

Multiple inheritance causes problems, if one or more of the parent classes defines members with same identifier. You would have to decide which parent to use to handle each method call, and the operation of class can be then very different than intended.And usually, there is no situations when multiple inheritance is needed. "Good" classes usually maps to some phenomenom or object, and very few things are at the same time  based on two different things. Usually when people wish to do multiple inheritance (is-a), a "has-a" relation is needed, meaning that a class contains some objects.Multiple inheritance is also highly discouraged in languages where it is supported (C++ etc.). Multiple inheritance is confusing at best.

Houssem Gharsallah
par Houssem Gharsallah , Software Architect , NOMD Technologies

To avoid confusion when having attributes or methods whith the same name.

This ambiguity often leads to non-deterministic behavior of classes in multiple inheritance languages. 

You can always use multiple inheritance with interfaces.

More Questions Like This