Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!usc!apple!uokmax!munnari.oz.au!comp.vuw.ac.nz!actrix!Bruce.Hoult From: Bruce.Hoult@bbs.actrix.gen.nz Newsgroups: comp.sys.mac.programmer Subject: Re: C++ vs Think C 4.0 Question Message-ID: <1990Nov30.100754.20661@actrix.gen.nz> Date: 30 Nov 90 10:07:54 GMT References: <1990Nov27.040144.27236@cunixf.cc.columbia.edu> <1990Nov27.163703.1323@actrix.gen.nz> <1990Nov29.181707.25001@nntp-server.caltech.edu> Sender: Bruce.Hoult@actrix.gen.nz (Bruce Hoult) Organization: Actrix Information Exchange, Wellington, New Zealand Lines: 46 Comment-To: woody@nntp-server.caltech.edu In article <1990Nov29.181707.25001@nntp-server.caltech.edu> woody@nntp-server.caltech.edu (William Edward Woody) writes: > In article <1990Nov27.163703.1323@actrix.gen.nz> Bruce.Hoult@bbs.actrix.gen.nz writes: > >Correct. Standard C++ doesn't have the "inherited" keyword. Apple have added > >it to their MPW C++ compiler, but only for objects derived from the special > >base class "PascalObject". They didn't allow it in general useage because > >they wanted to "avoid making gratuitous changes to C++". > > Actually, if you have the following declarations: > > [explanation of how to specify the base class explicitly] > > The problem with this keyword is when you have multiple inheritance. For > example: > > [example of a multiple inheritance hierachy] > > and in TObject3::foo() you say: > > void TObject3::foo() > { > inherited::foo(); > } > > do you mean TObject1::foo() or TObject2::foo()? > > C++ requires that you expressly indicate which function you are calling. > This is only a minor price to pay, IMHO, for the value of multiple > inheritance. > > -- Bill Well, thanks for telling me stuff I already knew :-) The fact that inherited can sometimes be ambiguous in multiple inheritance is no reason to not allow it. If your TObject3, above, had not defined foo() at all then there would have been the possibility of a client of the class attempting to call foo() -- and ambiguity rears its head again! The language specification says that it is OK to have a potential ambiguity and it is only when an *actual* ambiguous use is made that an error occurs. Following the same principle, "inherited" could be allowed even in multiple inheritance with the compiler warning of ambiguous usage. -- Bruce Hoult Bruce.Hoult@bbs.actrix.gen.nz