I just stumbled across an compile error and I am wondering why this occurs.
The code:
struct Foo1
{
virtual int foo() = 0;
};
struct Foo2 : Foo1
{
virtual int foo(int i) = 0;
};
struct Bar : public Foo2
{
virtual int foo() { return 0; }
virtual int foo(int i) { return i; }
};
int main() {
Bar b;
Foo2* f2 = &b;
b.foo();
//f2->foo(); // this gives an error
return 0;
}
The error on a gcc 4.8.1 is
error: no matching function for call to ‘Foo2::foo()’
I am wondering why the compiler cannot see the Foo1::foo
function?
I know that I can fix this by adding using Foo1::foo
to the Foo2
class, but can anyone give me a reference to the standard why the compiler is not able to find the function by itself?