|
|
Warp wrote:
>
> Usually these managers and their widgets can be kept separate, but in
> this one case I needed to be able to gave the same objects to both
> managers.
>
> Without multiple inheritance this would have been simply impossible.
> I can't think of any way to accomplish this if multiple inheritance was
> not supported. With C++'s multiple inheritance it worked beautifully.
> I could create objects which were of both widget types at the same time,
> and which could be given to both widget managers without even the
> slightest of problems.
>
> I just can't even begin to imagine how I could have done this eg. in
> Java. (At least not without crippling the system really badly and making
> it really cumbersome to use.)
It has its uses. There's no clean way to handle this situation in C# or
Java.
>
> Just avoid diamond inheritance if you are unsure. It's not that hard.
>
> Being able to inherit from two (completely distinct) classes is extremely
> handy regardless.
>
Only one problem with that: in both C# and Java, all classes have a
common base. So, with multiple inheritance, diamonds are a given. Rather
than address this, they chose to not allow multiple inheritance. I'm
guessing Java has interfaces, like C#.
>
> I don't like languages which artificially limit what I can do just
> because the creators feared diamond inheritance.
>
Not completely artificial. They made a design decision with the
language, which could potentially create problems later.
Post a reply to this message
|
|