On Mar 6, 2006, at 8:12 AM, Pierre Chatelier wrote:
Hello,
I cannot compile a code that seems correct to me. I have tried with
gcc 3.3 and gcc 4.0.1 on MacOS X-ppc, and gcc 4.0.1 on Linux i686.
Here is the code, that uses pure virtual functions and simple
inheritance.
//-------------------------------------
struct a
{
virtual int foo() =0;
virtual ~a(){}
};
struct b : public a
{
virtual int foo(int a) =0;
virtual ~b(){}
};
struct c : public b
{
int test()
{
return (foo() + // <--- the compiler claims here that it cannot
find foo()
foo(2));
}
virtual ~c(){}
};
This is not a bug in gcc. foo in b hides the one from a.
You can "fix" the source by:
struct b : public a
{
virtual int foo(int a) =0;
using a::foo;
virtual ~b(){}
};
Which interjects foo from a into b's "namespace".
-- Pinski