Path: utzoo!utgpu!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!rutgers!bellcore!faline!thumper!ulysses!andante!alice!bs From: bs@alice.UUCP (Bjarne Stroustrup) Newsgroups: comp.lang.c++ Subject: Re: Problem with multiple inheritance? (Long) Summary: virtual functions! Message-ID: <8442@alice.UUCP> Date: 19 Nov 88 02:49:04 GMT References: <8335@nlm-mcs.arpa> <3438@jpl-devvax.JPL.NASA.GOV> <941@etive.ed.ac.uk> Organization: AT&T Bell Laboratories, Murray Hill NJ Lines: 25 Dave Berry, Laboratory for Foundations of Computer Science, Edinburgh. beowulf.JPL.NASA.GOV (David Smyth): > >And more: you lose substitutablity when you use a virtual base class. > >Fancy cannot be on a list of windows, because you can't cast a pointer > >declared as a pointer to Window into a pointer to Fancy, or Bordered > >or Labeled for that matter. > > Now this is a problem. Can't C++ introduce a notion of cast that is > more sophisticated than the C notion, to handle cases like this? Try virtual functions. Naturally, I could make casts work from a virtual base class to a derived class (where the derived class is unambiguously specified), but I don't see much point in such an elaboration since we already have virtual functions as a cleaner mechanism. > If multiple inheritance doesn't provide the possibility of lists of > a given type including objects of a sub-type of that type, with > virtual members working properly, I don't think multiple inheritance > adds much, if anything, to the language. Exactly, so it does.