I have a class like so:
class A
{
public:
virtual void foo() { bar() }
protected:
virtual void bar() { /* do stuff */ }
}
Now I want a derived class B that overrides both foo and bar. So I wrote the following:
class B : public A
{
public:
virtual void foo() { A::foo(); /* then other stuff */ }
protected:
virtual void bar() { /* do different stuff */ }
}
Everything compiles but when I invoke B::foo I expect B::bar to get (eventually) called. Instead, I get A::bar. What am I doing wrong?