protected inheritance

前端 未结 4 1455
眼角桃花
眼角桃花 2021-01-11 19:30

Why protected and private inheritance are defined and proposed? I understand some cases private inheritance could be used but it is not recommended. How about protected inhe

4条回答
  •  暖寄归人
    2021-01-11 20:03

    This is a situation i would use Protected inheritance

    Base -> Derived1 -> Derived2

    • I dont want Derived1 to be substituted for the Base class
    • I want to use functionality in base and also allow the Derived2 to use it without exposing the functionality to client classes

提交回复
热议问题