Function overrides should not have a more restrictive interface

I stumbled upon this as a minor annoyance. Overriding public virtual functions with private functions in C++ - Stack Overflow
My base class has a public virtual function, and in the derived class the function override is private. It would be nice if this was a code smell, because it’s very weird, and you can always static cast to a reference to the base class anyway, which allows you to use the function.

I suppose there are subtleties like private inheritance, and I’m not sure about whether it’s reasonable for overrides to be more accessible.

Thanks for the idea @torgeir.skogen!
I created this ticket to follow up on it.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.