Should you ever use protected member variables?

后端 未结 10 1783
星月不相逢
星月不相逢 2020-12-02 07:53

Should you ever use protected member variables? What are the the advantages and what issues can this cause?

10条回答
  •  天涯浪人
    2020-12-02 08:22

    The general feeling nowadays is that they cause undue coupling between derived classes and their bases.

    They have no particular advantage over protected methods/properties (once upon a time they might have a slight performance advantage), and they were also used more in an era when very deep inheritance was in fashion, which it isn't at the moment.

提交回复
热议问题