A Constructor for a Object-Library is a method which is needed for creating an object. The constructor method is called by the compiler when an object is to be created/initialized. In object libraries at least one constructor for creating is necessary. The constructors for assignment to an object variable (ConstructorAssign) or copy (ConstructorClone), as well as the destructor are optional.
If a variable dimensioned by the type of the object library, it is undefined (nil). It is - as described - a pointer to a dynamic memoryblock. Once an object with the new-operator is created, this variable points to the allocated memory block.
How Much Memory is allocated for the object after creation, is defined by the author of the object library.
A constructor for creating (new) must therefore contain:
There are three different types of constructors in an object library that can be executed depending on the type of processing (creating, assigning, copying).
The parameters that are defined for a constructor that control how and what kind of input data to generate an object are possible. Since multiple constructors may be applied, this may also differ.
dim var as myobj var = new myobject()
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