Re: OT: C++ help
On Wed May 21 2008 20:01:10 Jordi Gutiérrez Hermoso wrote:
> On 21/05/2008, Mike Bird <mgb-debian@yosemite.net> wrote:
> > On Wed May 21 2008 19:00:27 Jordi Gutiérrez Hermoso wrote:
> > > The problem seems to be that all of my functions being named f are
> > > somehow colliding with each other.
> >
> > Annotated C++ Reference Manual, Ellis & Stroustrup, Section 13.1
> > (Declaration Matching). "A function member of a derived class is
> > not in the same scope as a function member of the same name in a
> > base class."
>
> So what's the fix here? Why does a using A::f declaration inside class
> B not work?
There's no f(int) in scope, only int(foo).
You could always switch to A's scope:
dynamic_cast<A*>(&b)->f(a);
But the best solution is to read up on WHY C++ works this way so
you can understand the implications that thousands of great minds
have already pondered.
--Mike Bird
Reply to: