Polymorphism
type TFigure = class procedure Draw; virtual; end; TRectangle = class(TFigure) procedure Draw; override; end; TEllipse = class(TFigure) procedure Draw; override; end;If the key word override is missing, then mehtod calls to the base class are not polymorphic and the base class method is called instead. In order to suppress compiler warnings, use the reintroduce directive if this is what you actually want.
virtual and dynamic perform the same function, but have different implementations.
abstract virtual methods define only the name, parameters, and return type of a method. One of the derived classes MUST define an implementation. You can not create objects until all the abstract methods of all the ancessor classes have implementations.
type TFigure = class procedure Draw; virtual; abstract; end;
Overload
function Add(a, b: Integer): Integer; overload; function Add(a, b: Real ): Real ; overload;The actual function called depends on the types of the parameters.
Default Parameters
function Mid_mc(string, start: integer; length: integer = -1):string; xx := mid_mc('abcdefg', 3); // xx = 'defg' - reads to end of string xx := mid_mc('abcdefg', 3, 2); // xx = 'de'There is no need to repeat the default values when the function details are specified.
In general, use overload for different types of parameters, default parameters for a different number of parameters.
(Search for default parameters in the Delphi 5 help.)
Named Parameters
I did find the following example, but that was all (see Named Parameters). Apparently, this syntax can only be used with Automation objects.
Word.FileSaveAs(Password := 'secret', Name := 'test.doc');Author: Robert Clemenzi - clemenzi@cpcug.org