Mixin vs inheritance

前端 未结 9 1010
梦毁少年i
梦毁少年i 2020-12-02 07:22

What is the difference between a mixin and inheritance?

9条回答
  •  被撕碎了的回忆
    2020-12-02 07:53

    tl;dr

    mixin and multiple inheritance have the same form. But have different semantics: mixin has the basic classes provide the function implementation. For inheritance, base classes provide interface and subclass has the implementation.

    But anyway, composition is preferred over mixin IMO

提交回复
热议问题