Possible Duplicate:
C++: rationale behind hiding rule
In this code sample from http://www.gotw.ca/gotw/005.htm, I was shocked to learn that in class Derived, f(int)
and f(double)
are not visible!
class Base {
public:
virtual void f( int ) {
cout << "Base::f(int)" << endl;
}
virtual void f( double ) {
cout << "Base::f(double)" << endl;
}
virtual void g( int i = 10 ) {
cout << i << endl;
}
};
class Derived: public Base {
public:
void f( complex<double> ) {
cout << "Derived::f(complex)" << endl;
}
void g( int i = 20 ) {
cout << "Derived::g() " << i << endl;
}
};
What is the reasoning behind this?
As I understand f( complex<double> )
has a different signature than the other two inherited versions of f().
- Why are all three not visible in this scenario?
- What are the ways to make sure the Base functions are visible in this case?