Why is my Base class's Constructor method never called?

I’m still using 2018 Release 2 because my Pro license expired two days before the release after it went public. In this Desktop project’s code every MsgBox except “Base Constructor” appears when run by clicking the “Run” button. Why is that?

[code]Class Base
Method Constructor Scope Public
MsgBox “Base Constructor”

Method build Scope Protected
MsgBox “Base.Build”

Class Derived Super Base
Method Constructor Scope Public
MsgBox “Derived Constructor”

Method build Scope Public
MsgBox “Derived.Build”

Window1.Open
Dim d As Derived = New Derived
d.build

’ Dim As Base causes “Method Protected” error
[/code]

you need to call SUPER.CONSTRUCTOR in the derived class
otherwise you are just overriding/replacing it

This is different from Destructor, btw, which is always called at every level back to the base class.

Kem: What is the Destructor’s calling order, Deepest up or Newest down? Your “back to” comment seems to imply it’s Newest down.

The destructor order is: once the current object starts being removed, it calls the self.destructor() and then the super.destructor(), and after, it destroys itself. So, the final sequence is current_object.destructor() then parent_object.destructor() and so on in chain.

Interestingly. When I called Quit() in a test, I couldn’t see the destruction chains in system.debuglog. I only saw it if I forced them out of scope before it.

[code]//----- Classes
Class Class1
Methods
Sub Destructor()
System.DebugLog “destroy 1”
End Sub
End Class

Class Class2 Inherits Class1
Methods
Sub Destructor()
System.DebugLog “destroy 2”
End Sub
End Class

//---- tests

Window1.Controls.PushButton1:
Sub Action()

Dim c as new Class2

Quit // No destructor seems called here

End Sub

//-----

Window1.Controls.PushButton2:
Sub Action()

If True Then
Dim c as new Class2
End // class2.destructor() and later class1.destructor() are called

Quit

End Sub[/code]