Java Multiple Inheritance

前端 未结 17 1455
猫巷女王i
猫巷女王i 2020-11-22 09:36

In an attempt to fully understand how to solve Java\'s multiple inheritance problems I have a classic question that I need clarified.

Lets say I have class Ani

17条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-22 10:37

    Problem not solved. To sufficiently model this out and to prevent code replication you'd either need multiple inheritance or mixins. Interfaces with default functions are not sufficient because you cannot hold members in interfaces. Interface modeling leads to code replication in subclasses or statics, which is both evil.

    All you can do is to use a custom construction and split it up in more components and compose it all together...

    toy language

提交回复
热议问题