How to prevent derived class from making a private/protected virtual function public?

前端 未结 6 1081
梦谈多话
梦谈多话 2020-12-20 23:18

There are good reasons for constructing the base class interface with all virtual functions as private or protected (see this). But then how does one prevent the derived cla

6条回答
  •  囚心锁ツ
    2020-12-21 00:11

    Promoting a private/protected virtual method to public in a derived class does not expose the base class method. It still cannot be called through a base class pointer. It does not become part of the interface of the base clase.

提交回复
热议问题