Originale-mail to me for new edition

 

Compatibility of class types

 

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.

 

Topic groups

 

See also

About class types

Inheritance and scope

Type compatibility and identity: Overview

 

 

译文

 

类类型的兼容性

 

类类型对其祖先是赋值兼容的。因此,类类型的变量可以引用其所有子孙类型的实例。例如,给出如下声明,

type

  TFigure = class(TObject);

  TRectangle = class(TFigure);

  TSquare = class(TRectangle);

var

  Fig: TFigure;

变量Fig可以被赋予TFigureTRectangleTSquare等类型的值。

 

主题组

 

相关主题

关于类类型

继承和作用域

类型兼容和等同:概述