Mike Bird wrote:
On Wed May 21 2008 20:01:10 Jordi Gutiérrez Hermoso wrote:
On 21/05/2008, Mike Bird <[EMAIL PROTECTED]> 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).
Which... the compiler kindly tells us:
do_foo.cpp: In function 'int main()':
do_foo.cpp:18: error: no matching function for call to 'B::f(int&)'
do_foo.cpp:12: note: candidates are: virtual void B::f(foo)
make: *** [do_foo.o] Error 1
Hugo
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.
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]