Visual Basic .NET » Internet / Hardware Communication
Y multiple inheritance is not supported by .net -- sunny --


hi, evy bdy , i m new to ASP.net need's guidance,Is it wantedly avoided, if yes then why and its disadventages.

-- BradleyPeter --


Heh! Check the archives. We've answered this at some length already.
Are you guys doing the same course?

:)

Peter

-----Original Message-----
From: DotNetDevelopment
Y multiple inheritance is not supported by
.net
hi, evy bdy , i m new to ASP.net need's guidance,Is it wantedly avoided, if yes then why and its disadventages.


-- Cerebrus --


Lol ! If I recall correctly, that guy asked the question and mentioned he keeps getting this question in interviews.

-- Sevinfooter --


I am stabbing blindly at this, but I believe the reason is that logically, every form should have a single base class. If its a web form, it will inherit the web stuff. If it is a windows form, it will have windows form inheritance. You may then extend this base class in anyway you want by overriding methods, or adding properties, or whatever you want. You can add web functionality to a windows form by using web and COM+ references. You are limitted to the functionality you add to web forms however. For instance, you may not use msgbox in web forms.

HTH

-- BradleyPeter --

Here's what I posted the last time this question was asked:

I can't speak for the C# team, but I can give you a general answer.

Multiple inheritance is problematic every time there is an "Inheritance Diamond" - i.e. when two, or more, classes you are extending share a common ancestor. The difficulty is that the same method might be defined in several different ways by several different classes in the diamond.

For example, let's say that the ultimate ancestor defines a method Draw(). Now let's imagine that the ultimate ancestor has two children,
both of whom override the Draw() method, in two different ways.

Finally, let's imagine that a class is defined that inherits from both those children, but does not override the Draw() method. Now, when a call is made to Draw() in code, how is the compiler to determine which Draw() method to call? It has no way of knowing whether it should call the Draw() method of the first child or the second child of the ultimate ancestor.

Languages that support multiple inheritance address this problem in a number of ways. C++, for example, depends on virtual inheritance to determine which method to call. Perl and Lisp rely on depth first searches of the inheritance tree; and call the first method with the appropriate signature found in the search. Either way, it's clunky and relies on the programmer understanding detail that should not be necessary.

The designers of Java and C# have probably taken the view that there are too many problems inherent in multiple inheritance. Instead they have chosen to simulate multiple inheritance through the use of interfaces.
In most cases this is perfectly acceptable. You usually want multiple inheritance for behaviour reasons (i.e. because you want to use the interface provided by one of the parents). Java and C# allow you to make this explicit.

HTH

Peter
-----Original Message-----
From: DotNetDevelopment on behalf of Sevinfooter Sent: Mon 7/17/2006 3:23 PM To: DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting Cc:
Subject:
Re: Y multiple inheritance is not supported by .net
I am stabbing blindly at this, but I believe the reason is that logically, every form should have a single base class. If its a web form, it will inherit the web stuff. If it is a windows form, it will have windows form inheritance. You may then extend this base class in anyway you want by overriding methods, or adding properties, or whatever you want. You can add web functionality to a windows form by using web and COM+ references. You are limitted to the functionality you add to web forms however. For instance, you may not use msgbox in web forms.

HTH



[Submit Comment]Home