Possible Duplicate:
overloaded functions are hidden in derived class
It seems that I cannot directly use methods from a base class in a derived class if they are overloaded in both the base class and the derived class in C++. The following code produces the error no matching function for call to ‘Derived::getTwo()’
.
class Base {
public:
int getTwo() {
return 2;
}
int getTwo(int, int) {
return 2;
}
};
class Derived : public Base {
public:
int getValue() {
// no matching function for call to ‘Derived::getTwo()’
return getTwo();
}
int getTwo(int) {
return 2;
}
};
If I change return getTwo();
to return ((Base*) this)->getTwo()
, it works, but that looks ugly to me. How can I fix this?
P.S. I use g++ 4.7 with option std=gnu++c11, if that matters.