Class methods are methods that do not have an instance, but which follow the scoping and inheritance rules of a class. They can be called from inside a regular method, but can also be called using a class identi er:
Var
AClass : TClass; begin .. if CompareText(AClass.ClassName,'TCOMPONENT')=0 then ... |
But calling them from an instance is also possible:
Var
MyClass : TObject; begin .. if MyClass.ClassNameis('TCOMPONENT') then ... |
Inside a class method, the self identi er points to the VMT table of the class. No elds, properties or regular methods are available inside a class method. Accessing a regular property or method will result in a compiler error. The reverse is possible: a class method can be called from a regular method.
Note that class methods can be virtual, and can be overridden.
Class methods cannot be used as read or write speci ers for a property.