why derive from a concrete class is a poor design

前端 未结 5 1664
离开以前
离开以前 2020-12-09 04:21

I was reading about NonVirtual Interface pattern: Herb Sutter is talking about why virtual function must be private in most of the case, protected in some case and never pub

5条回答
  •  难免孤独
    2020-12-09 04:36

    I think this is because concrete class has concrete behavior. When deriving from it, you are committed to retain the same "contract", but the actual contract is defined by the specific implementation of the base class, and in reality will have many subtleties you will probably break without knowing.

    Disclaimer: I am not an experienced developer; it is just a suggestion.

提交回复
热议问题