Ok, I have a class, let’s call it SuperClass, and a subclass, let’s call it SubClass that extends SuperClass. SuperClass has a protected method that adds a child to the instance of SubClass.
Thit method gets called when SubClass is instantiated (through the “super()” call) or later directly from a SubClass instance.
I would have thought that in both cases, the child that is added is a child of the SubClass instance (since technically the superclass is only instantiated as the subclass). However, I get different results when I trace out the parent hierarchy for the added child.
Why is this, and how do I ensure that the child that is added is added to the subclass instance?