Libraries - Type Constructor

A constructor for a type library is a method that is used for generating an object. The constructor method is called by the compiler when an object is to be created / initialized. For Type Libraries a constructor is optional, since the memory of the object is static as in a structure.

If a variable dimensioned by the type of the type library, it is already the space in the specified size.

How Much Memory an type-object allocates is defined by the author of the Type Library.

In the type library, there is only an optional standard constructor.

  1. Constructor - Called to create/initialize an type-object: new myobject(…). The created object is then temporarily stored in memory (on the stack) and is not assigned to a variable. More than one constructor are allowed.

The assignment to a variable, copying (cloning) or destroying is performed automatically by internal built-in functions.

The parameters that are defined for a constructor controls how and what kind of input data are possible while creating an type-object . Since multiple constructors may be applied, this may also differ.

Example 1

Constructor()
dim var as myobj
var = new myobject()

Example 2

Constructor(size as byte)
dim var as myobj
var = new myobject(123)
'following term selects and calls automatically the
'best-fit constructor with the value as parameter (like above):
var = 123