ابدأ بالتواصل مع الأشخاص وتبادل معارفك المهنية

أنشئ حسابًا أو سجّل الدخول للانضمام إلى مجتمعك المهني.

متابعة

Why .net does not multiple inheritance?

user-image
تم إضافة السؤال من قبل AJAM KHAJA SHAIK
تاريخ النشر: 2013/10/25
Mohammed Sadique
من قبل 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
من قبل 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.

المزيد من الأسئلة المماثلة