I have the following code:
class A
{
public:
virtual void foo( void ) = 0;
virtual void foo( int ) { }
};
class B : public A
{
public:
virtual void foo( void ) override { }
};
class C : public B
{
public:
virtual void foo( int n ) override
{
B::foo( n );
}
};
I checked that code with different compilers and all of them show the same bug: There is no B::foo(n) function to call inside the C::foo(int) function.
According to my non-so-updated c++ knowledge:
- A has two different functions signatures.
Boverridesfoo(): a pure virtual function of classA. It inheritsfoo(int)for free. In other words,foo(int)should be a function available to the public interface ofB.- The public interface of
Cshould have thefoo()function inherited fromBand overridesfoo(int)function that should be available from the public interface ofB. InsideC::foo(int)I would call its overridden method fromB,B::foo(int).
What were you expecting?
Since B inherits publicly from A, it should have in its public interface foo(int) and from that
I would expect to call B::foo(int) inside C::foo(int).