This doesn't work:
class Foo
{
public:
virtual int A(int);
virtual int A(int,int);
};
class Bar : public Foo
{
public:
virtual int A(int);
};
Bar b;
int main()
{
b.A(0,0);
}
It seems that by overriding Foo::A(int)
with Bar::A(int)
I have somehow hidden Foo::A(int,int)
. If I add a Bar::A(int,int)
things work.
Does anyone have a link to a good description of what's going on here?
Essentially, name lookup happens before overload resolution so the function A
in your derived class overrides the virtual function in the base class but hides all other functions with the same name in any base classes.
Possible solutions include adding a using Foo::A;
directive into your derived class to make all the base class members called A
visible in the derived class or using different names for functions with different signatures.
See here as well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With