Discussion: OT: C++ help
Afficher un message
Vieux 22/05/2008, 05h20   #4
Mike Bird
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: OT: C++

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


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
  Réponse avec citation
 
Page generated in 0,06379 seconds with 9 queries