A cool design about inheritance is that allows access to protected methods,
properties and fields and not allows the access to any class that is not
derived from it.
Multi inheritance can be a design nightmare, but it can't be emulated.
Creating a wrapper containing instances of the classes you want to inherit
won't let you access to protected methods, properties and fields. The only
thing it will do is a super class with public methods and properties from
the instances inside it. Also this is messy because you have to create a
wrapper for each method you want to expose from each instance inside the
super class, for example if you want to expose the methods of 2 classes
where each one has 20 methods, then you need to create 40 wrappers methods.
I didn't understand what you mean with design nightmare.
Is it a nightmare for the designer of the language or is it a nightmare for
the programmer using it?
I think muti-inheritance should be used when really is necessary, and there
cases where it is pretty useful and "emulate" it is almost impossible.
For example:
I needed inherit each Windows control to enhance it with some functionality.
This extra code is complex and requires use properties and methods from the
base control.
If I create an extra class to make the enhancement then I need create
methods accepting a lot of parameters creating a crappy design, also inside
the wrapper class don't let me access to the methods from the base control;
a solution is sending a instance of the derived control to the wrapper
class, but inside the wrapper class doesn't let you access to protected
methods from the base control.
To fix that is nescesary create a wrapper "public method" from the protected
method and send the control instance to the wrapper class, but then these
methods will be accessed for any class.
They could be declared as "internal methods", but it doesn't solve the
problem because now those methods are exposed to the complete assembly.
Finally the only solution was duplicating the code on each control derived
from Windows control.
Where maintain the code is a pain, one change on the enhancement logic
require change every control logic.
Muti-inheritance could have solved the problem really nicely.
Gustavo.
[quoted text, click to view] "Matthijs van der Vleuten" <microsoft-nntp@chroma.mine.nu> wrote in message
news:eZJoy$llFHA.3256@tk2msftngp13.phx.gbl...
> Boomessh wrote:
>> Hi all,
>>
>> I wanted to know the reason Why in .NET multiple inheritance is not
>> supported? Thanks,
>> V.Boomessh
>
> It's a design nightmare.
>
> By the way, you CAN emulate it. Create a wrapper class containing
> instances of the classes you want to inherit.