Passing Derived class as a parameter to a method when the parameter type is base class

前端 未结 4 2272
暖寄归人
暖寄归人 2020-12-05 04:20

I am a newbie and trying to understand concepts of inheritance and design patterns.

I came across this pattern http://en.wikipedia.org/wiki/Strategy_pattern when I w

4条回答
  •  独厮守ぢ
    2020-12-05 04:22

    The derived class is a base class. (That's the whole concept of inheritance: inheritance defines an 'is a' relationship).

    Also, check out the Liskov substitution principle. :)

提交回复
热议问题