Multiple inheritance in Java/C#

Dieter Maurer dieter at handshake.de
Thu Nov 20 14:18:42 EST 2003


"Sean Ross" <sross at connectmail.carleton.ca> writes on Wed, 19 Nov 2003 10:24:27 -0500:
> "Hung Jung Lu" <hungjunglu at yahoo.com> wrote in message
> news:8ef9bea6.0311182031.38034c10 at posting.google.com...
> > Does anyone know how to emulate Python-like MI in Java/C#?
> ...

> "the delegator pattern", I'm not
> sure. I know that for doing CORBA programming with Java, you can have tie
> classes (which I believe use the aforementioned design pattern) generated to
> help simulate multiple inheritance. The idea is something like this: you
> have class C which inherits from A but you would like to have a class that
> inherits from A and B; make a class D that inherits from B, and that keeps
> an instance of C; D is your class that "inherits" from A and B; when you
> have an instance of d and you call a method derived from A, you delegate to
> the instance of C, otherwise you handle it directly. I think that's the
> general idea. You should be able to find specific examples somewhere online.

That is indeed the general approach.
And, as you see, you write lots of trivial delegation code.
Trivialities that the compiler would do for you -- had you a
language with multiple inheritance.


Dieter




More information about the Python-list mailing list