Why is it preferred to have non-virtual interfaces?

前端 未结 2 1489
臣服心动
臣服心动 2021-01-17 01:10

I am going through this article http://www.gotw.ca/publications/mill18.htm by Herb Sutter. The author mentions that writing non-virtual interfaces separates the interface sp

2条回答
  •  时光说笑
    2021-01-17 01:25

    When you specify the virtual public interface, int Process( Gadget& );, you are also restricting the extension interface to match this public interface. Whoever extends this class will need to do this by implementing the Process function.

    Providing a cleaner public interface and a more suitable [batch] of well designed private functions for customization will allow tackling our two goals individually.

提交回复
热议问题