Name

Reintroduce Directive

Syntax

Method declaration; reintroduce;

Description

A derived class uses the reintroduce directive to hide the name of a virtual or dynamic method that was declared in a base class. Without the directive, the compiler warns you that the derived class is hiding the ancestor’s method. Hiding, in this context, means that you cannot call the ancestor method if you have an object reference whose type is the derived class. Any attempt to call the method actually calls the derived class’s method.

Tips and Tricks

The reintroduce directive, if it appears, must be the method’s first directive.

Example

type
  TVector = class
  public
    procedure Add(Item: Integer); virtual;
  end;
  TSingleVector = class
  public
    // The TSingleVector.Add method hides TVector.Add, so the compiler
    // warns you about this. If you are hiding the method deliberately,
    // say so with the reintroduce directive.
    procedure Add(Item: Single); reintroduce;
  end;

See Also

Dynamic Directive, Function Keyword, Override Directive, Procedure Keyword, 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.