A class subclass of itself. Why mutual subclassing is forbidden?

后端 未结 6 638
天命终不由人
天命终不由人 2021-01-12 21:25

Complex question I assume, but studying OWL opened a new perspective to live, the universe and everything. I\'m going philosophical here.

I am trying to achieve a cl

6条回答
  •  时光取名叫无心
    2021-01-12 21:46

    I think the answer is "When you construct class C ... it must create instance of class B .. which must create instance of class C ... and so on" This will never end. This is forbidden in most languages (in fact i don't know other case). You can only create an object with a 'reference' to other object that can be initially null.

提交回复
热议问题