Name

Dynamic Directive

Syntax

Method declaration; dynamic;

Description

You can declare a virtual method in a base class by using the virtual directive or the dynamic directive. The semantics of both directives is the same. The only difference is the implementation of the method and how it is called. For details, see Chapter 3.

As with a virtual method, derived classes must use the override directive to override the method.

Tips and Tricks

  • You should almost always use the virtual directive instead of dynamic. In most cases, virtual methods are faster and take up less memory than dynamic methods.

  • The dynamic directive must follow the reintroduce and overload directives and precede the calling convention and abstract directives.

See Also

Abstract Directive, Class Type, Overload Directive, Override Directive, Reintroduce Directive, Virtual Directive

Get Delphi in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.