In other words if I have a class
class A
{
public:
A() { .. }
virtual void somemethod() { .. }
};
is it ok to write
class B : public A
{
public:
B() { .. }
protected:
virtual void somemethod() { .. }
};
or are there some drawbacks with this approach?
I would say this defeats the purpose of polymorphism, because when you write a function that accepts a polymorphic type, the derived type should work equally well with it:
IMHO, it depends on the specific problem you are trying to solve because I don’t believe in “always” successful “best practice”.