[Date Prev][Date Next][Thread Prev][Thread Next][Author Index][Date Index][Thread Index]

C++ inheritance and overloading problems



I'm not sure shadowing is a design bug.  Imagine:

CLASS(Derived,Base);
Base::fun(Base * arg) {...}
Derived::fun(Derived * arg) {...}
...
{   Base * p;
    Derived * q = new Derived();

    p = Derived();
    p ->fun(q);
}

I think this is the example I want.  Think about the type resolution
rules required.  I'm sure I could come up with an intractable example.
This results from the interaction between runtime dispatch and
compile-time dispatch.  I expect they decided that subclasses can't
redefine the types of member functions without overriding the
inherited type.

dean