Path: utzoo!attcan!uunet!mcsun!cernvax!chx400!bernina!neptune!inf.ethz.ch!brandis From: brandis@inf.ethz.ch (Marc Brandis) Newsgroups: comp.object Subject: Re: Examples of Multiple Inheritance? Keywords: multiple inheritance Message-ID: <18090@neptune.inf.ethz.ch> Date: 12 Dec 90 16:11:57 GMT References: <17562@neptune.inf.ethz.ch> <60700005@inmet> <980@culhua.prg.ox.ac.uk> <841@echbull.bull.fr> Sender: news@neptune.inf.ethz.ch Reply-To: brandis@inf.ethz.ch (Marc Brandis) Organization: Departement Informatik, ETH, Zurich Lines: 46 In article <841@echbull.bull.fr> Marc.Herrmann@ec.bull.fr () writes: >> Very often, the kind of situations that you are describing can be >> solved by using references to other objects and just deriving from one class. > > By doing so don't you implement multiple inheritance by using simple >inheritance + delegation ? Could you clarify your point? > I do not implement (!) multiple inheritance, but instead achieve a similar effect using simple inheritance and delegation. There are several reasons why I think this is advantegeous to implementing multiple inheritance. First, there is no really clean way to solve the naming and consistency conflicts that arise when using multiple inheritance. I do not want to list them here as I think you know them. If one will be found, I have no major objection against multiple inheritance any more. However, I am not sure whether it will ever be found. As long as these conflicts are not resolved, I prefer to see in my code what is going on instead of having to guess what the compiler will do. I know that I may have to write a little more using simple inheritance and delegation, but everything is under complete control of the programmer. Second, multiple inheritance is a rather expensive construct (compared to single inheritance). In C++, you even have to pay some overhead when you are just using single inheritance because multiple inheritance has been added. I do not think that the few places where I could use multiple inheritance instead of some kind of delegation are worth this overhead. Third, as multiple inheritance is a rather powerful construct, which - at least at the moment - requires a lot of rules how conflicts are resolved, I would assume that lots of programmers may not understand all these rules well, so that they may introduce more errors than necessary. Just one note: I do not want to start a flame war on this. This has been discussed by many people before and lots of researchers do not agree on it. It is just that I am one of the people that are not convinced that multiple inheritance is worth the problems it causes. Marc-Michael Brandis Computer Systems Laboratory, ETH-Zentrum (Swiss Federal Institute of Technology) CH-8092 Zurich, Switzerland email: brandis@inf.ethz.ch