Is Inheritance really needed?

后端 未结 22 2106
孤街浪徒
孤街浪徒 2020-12-14 00:20

I must confess I\'m somewhat of an OOP skeptic. Bad pedagogical and laboral experiences with object orientation didn\'t help. So I converted into a fervent believer in Visua

22条回答
  •  攒了一身酷
    2020-12-14 00:56

    Inheritance and Composition have their own pros and cons.

    Refer to this related SE question on pros of inheritance and cons of composition.

    Prefer composition over inheritance?

    Have a look at the example in this documentation link:

    The example shows different use cases of overriding by using inheritance as a mean to achieve polymorphism.

提交回复
热议问题