vbscript Init Method to Emulate a Parameterized Constructor


Example

Class Car
    ...
    ' Parameterless Constructor
    Public Sub Class_Initialize()
        distances_ = Array(0)
    End Sub

    ' Default initialization method that can be invoked without
    ' explicitly using the method name.
    Public Default Function Init(wheels)
        wheels_ = wheels
        Set Init = Me
    End Function
    ...
End Class

Set car1 = (New Car)(18)       ' implicit invocation
Set car2 = (New Car).Init(8)   ' explicit invocation