Perhaps my knowledge of inheritance and polymorphism isn't what I thought it was. Can anyone shed some light?
Setup (trivialization of problem):
class X {
};
class Y {
};
class Base {
public:
void f( X* ) {}
};
class Child: public Base {
public:
void f( Y* ) {}
};
Question: This should work, right?
int main( void ) {
X* x = new X();
Y* y = new Y();
Child* c = new Child();
c->f( x );
c->f( y );
return 0;
}
I get errors (GCC 4.4) to the tune of:
`no matching function for call to 'Child::f(X*&)'`
`note: candidates are: void Child::f(Y*)`