Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!uunet!microsoft!jimad From: jimad@microsoft.UUCP (Jim ADCOCK) Newsgroups: comp.lang.c++ Subject: Re: renaming Message-ID: <54976@microsoft.UUCP> Date: 31 May 90 18:36:39 GMT References: <18591@orstcs.CS.ORST.EDU> Reply-To: jimad@microsoft.UUCP (Jim ADCOCK) Organization: Microsoft Corp., Redmond WA Lines: 83 In article <18591@orstcs.CS.ORST.EDU> budd@mist.CS.ORST.EDU (Tim Budd) writes: >When using inheritance, particularly multiple inheritance, it seems I often >miss the ability to do renaming, as in Eiffel. > >Expanding on the syntax used to create pure virtual functions, it would be >nice to do something like the following: > >class foo : public bar, pubic baz { > ... > void gak(int i) = bar::geek; > .. >} > >where geek is a method defined in bar which takes the same argument list as >gak. As it stands, now I have to do something like the following > >class foo : public bar, pubic baz { > ... > void gak(int i) { bar::geek(i); } > .. >} > >which is arguably no less readable, but does introduce the run-time >overhead of one additional function invocation. There shouldn't be one additional function invocation in the example you give, since gak(int i) is an inline function. Try compiling and looking at the code the following simple example generates. On my system [as in all C++ systems -- I think!] renaming causes no extra code to be generated. extern "C" { #include } class BASE { public: virtual void Print(); }; void BASE::Print() { printf("BASE@ %lX\n",(long)this); } class FOO: public BASE { public: void BASE_Print() { BASE::Print(); } void Print(); }; void FOO::Print() { printf("FOO @ %lX\n",(long)this); } class BAR: public BASE { public: void Print(); }; void BAR::Print() { printf("BAR @ %lX\n",(long)this); } class FOOBAR: public FOO, public BAR { public: void FOO_Print() { FOO::Print(); } void BAR_Print() { BAR::Print(); } void Print(); }; void FOOBAR::Print() { printf("FOOBAR @ %lX\n",(long)this); } int main() { FOOBAR foobar; foobar.BASE_Print(); foobar.FOO_Print(); foobar.BAR_Print(); foobar.Print(); printf("\n"); FOOBAR* pfoobar = new FOOBAR; pfoobar->BASE_Print(); pfoobar->FOO_Print(); pfoobar->BAR_Print(); pfoobar->Print(); }