Topic: inherited: : keyword


Author: fjh@munta.cs.mu.OZ.AU (Fergus Henderson)
Date: 1995/05/18
Raw View
hamilton@io.com (Jim Hamilton) writes:

>There's a problem with an "inherited::" keyword and multiple inheritance.

No, you've got it backwards.  The real problem occurs with the typedef
workaround.

>class DerivedFromAandB : public A, public B {
>   virtual foo();
>};
>
>DerivedFromAandB::foo()
>{
>   inherited::foo();    // which base's foo is called?
>}
>
>A typedef in DerivedFromAandB would explicitly solve this,
>but a keyword would have a pretty tough time.

No, it wouldn't.  A considerably more common case with multiple
inheritence would be to have calls to inherited::foo() and
inherited::bar() and want them to resolve to A::foo() and B::bar()
respectively.  A keyword could handle this easily, but the typedef
solution fails miserably.

I would expect the situation where ambiguity arises to be much rarer.
When it does arise, the right place to resolve the ambiguity is at
the point where it occurs, i.e. the call to inherited::foo().  It should
not be resolved at a single place in the class declaration, since the
correct resolution may be different for different functions.

--
Fergus Henderson                       | I'll forgive even GNU emacs as
fjh@cs.mu.oz.au                        | long as gcc is available ;-)
http://www.cs.mu.oz.au/~fjh            |             - Linus Torvalds