Class methods are identified by the keyword Class in front of the procedure or function declaration, as in the following example:
Class methods are methods that do not have an instance (i.e. Self does not point to a class instance) but which follow the scoping and inheritance rules of a class. They can be used to return information about the current class, for instance for registration or use in a class factory. Since no instance is available, no information available in instances can be used.
Class methods can be called from inside a regular method, but can also be called using a class identifier:
But calling them from an instance is also possible:
The reverse is not possible: Inside a class method, the Self identifier points to the VMT table of the class. No fields, properties or regular methods are available inside a class method. Accessing a regular property or method will result in a compiler error.
Note that class methods can be virtual, and can be overridden.
Class methods cannot be used as read or write specifiers for a property.