In Delphi, the static keyword is used exclusively to define class methods. In Delphi, the Regular Class Method can be declared virtual and overridden in a subclass. In addition, Delphi has a self variable similar to this pointer in other languages. However, in the class method itself points to the class in which the method is called instead of the instance.
Declaring a static class method means:
- It cannot be overridden in a subclass.
- It does not have a pointer to self
This means that a method of a static class can only access members of the class in the class in which it was defined, while a normal class method can access the overridden members of the class in derived classes.
There is another unofficial use of statics in the Delphi documentation, usually referring to function insensitivity (is that a word?). For example, a static array versus a dynamic array. All instance methods in Delphi are static unless otherwise specified.
Kenneth Cochran Mar 06 '09 at 19:44 2009-03-06 19:44
source share