class Base
{
// Declares two versions of foo
public:
void foo (void)
{}
public:
void foo (int i)
{}
};
class Derived : public Base
{
// Overloads the first version of foo in the base class
public:
void foo (void)
{}
};
int main (void)
{
Derived o;
o.foo (0); // cannot access foo (int) from Base
}
It generates the following compilation error:
1 2 3
main.cxx: In function ‘int main()’:
main.cxx:22: error: no matching function for call to ‘Derived::foo(int)’
main.cxx:15: note: candidates are: void Derived::foo()
If there any way to overload only one version of a polymorphic function in the derived class, and able to call all other un-overloaded versions from the base class?
Those functions are not polymorphic ( they weren't declared virtual )
If this non-polymorphic behaviour is what you intended, try adding using Base::foo; in the derived class