Overriding public virtual functions with private functions in C++

前端 未结 7 578
隐瞒了意图╮
隐瞒了意图╮ 2020-11-27 02:51

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:

7条回答
  •  -上瘾入骨i
    2020-11-27 03:20

    There's no technical problem, but you will end up with a situation where the publicly available functions will depend upon whether you have a base or derived pointer.

    This in my opinion would be weird and confusing.

提交回复
热议问题