PC-Lint issues a warning when a method is overriden in a derived class with access specifier other than what is the inherited access. For example
class B {
public:
virtual void fubar(void);
};
class D : public B {
private:
virtual void fubar(void);
};
One explaination I've seen is that the above would violate the Liskov Substitution Principle, but that's only case where the derived class has stricter access (like the example above), right? I'm also noting that here's a backdoor to D::fubar since we can cast a reference/pointer to D to reference/pointer to B and then we can call D::fubar since it's virtual. Is there any other problems?
What about if the derived class has looser access? For example:
class B {
protected:
virtual void fubar(void);
};
class D : public B {
public:
virtual void fubar(void);
};
Is there any problems associated with this type of override?