Is there is any reason to make the permissions on an overridden C++ virtual function different from the base class? Is there any danger in doing so?
For example:
class base {
public:
virtual int foo(double) = 0;
}
class child : public base {
private:
virtual int foo(double);
}
The C++ faq says that it is a bad idea, but doesn't say why.
I have seen this idiom in some code and I believe that the author was attempting to make the class final, based on an assumption that it is not possible to override a private member function. However, This article shows an example of overriding private functions. Of course another part of the C++ faq recommends against doing so.
My concrete questions:
Is there any technical problem with using a different permission for virtual methods in derived classes vs base class?
Is there any legitimate reason to do so?