A class type is
assignment-compatible with its ancestors. Hence a variable of a class type can
reference an instance of any descendant type. For example, given the
declarations
type
TFigure = class(TObject);
TRectangle = class(TFigure);
TSquare = class(TRectangle);
var
Fig: TFigure;
the variable Fig can be assigned values of type TFigure, TRectangle, and TSquare.
Type compatibility and identity: Overview
类类型对其祖先是赋值兼容的。因此,类类型的变量可以引用其所有子孙类型的实例。例如,给出如下声明,
type
TFigure = class(TObject);
TRectangle = class(TFigure);
TSquare = class(TRectangle);
var
Fig: TFigure;
变量Fig可以被赋予TFigure、TRectangle和TSquare等类型的值。