I have a very basic question concerning inheritance in C++:
class A
{
public:
void foo() { print(); }
protected:
void print() {}
};
class B : public A
{
protected:
void print() { std::cout << "test" << std:: endl; }
};
Now the following code
B b;
b.foo();
doesn't print anything, so foo() obviously didn't call the newly defined print(). Is this only solvable by using virtual methods?