On 21/05/2008, Mike Bird <[EMAIL PROTECTED]> wrote: > On Wed May 21 2008 20:01:10 Jordi Gutiérrez Hermoso wrote: > > > 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).
No, no, wait. This makes no sense. Consider class foo{}; class A{ public: void f(int a ){a++;}; private: virtual void f(foo a) = 0; }; class B : public A{ public: using A::f; private: virtual void f(foo a){}; }; int main(){ B b; int a=0; b.f(a); } versus class foo{}; class A{ public: void f(int a ){a++;}; public: virtual void f(foo a) = 0; }; class B : public A{ public: using A::f; public: virtual void f(foo a){}; }; int main(){ B b; int a=0; b.f(a); } The *only* thing that changed is the access specifiers. For some reason, the name lookup works and it seems that the compiler understands that "using A::f" means "A::f(int)" when some function is public but fails when the function is private, and tries instead to interpret "using A::f" as "A::f(C)". The first example fails to compile, but the second one does. > 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. Well, those great minds seem to be too great for me to fathom, because I really don't see why it seems here that a function's signature isn't enough to specify it, and they saw it fit to make sure I couldn't both I overload and inherit three related but different functions. C++ isn't perfect, the standard isn't gospel, and I'm beginning to suspect a bug in gcc. - Jordi G. H. -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]