how to inherit from multiple class

前端 未结 5 760
自闭症患者
自闭症患者 2021-02-09 17:59

Let\'s say i have a griffon object that needs to be part of the felidae and bird class.
How do i do it ?
I can only make it inherit from 1 class at a time...

5条回答
  •  爱一瞬间的悲伤
    2021-02-09 18:27

    You can dynamically create a class at runtime and choose the methods of each parent class to inherit. Have a look at the NeXT runtime's documentation here about dynamically creating classes. I did this once just for fun, but I didn't get very far as it gets incredibly messy very quickly.

    Edit

    It gets more difficult though, because there can only be one superclass, otherwise the keyword super becomes ambiguous.

提交回复
热议问题