1.类的声明格式
type className = class [abstract | sealed] (ancestorClass) memberList end;
2.类的声明和使用
//定义 type TMemoryStream = class(TCustomMemoryStream) private FCapacity: Longint; procedure SetCapacity(NewCapacity: Longint); protected function Realloc(var NewCapacity: Longint): Pointer; virtual; property Capacity: Longint read FCapacity write SetCapacity; public destructor Destroy; override; procedure Clear; procedure LoadFromStream(Stream: TStream); procedure LoadFromFile(const FileName: string); procedure SetSize(NewSize: Longint); override; function Write(const Buffer; Count: Longint): Longint; override; end;//使用 var stream: TMemoryStream; stream := TMemoryStream.Create;
3.类的继承
//继承一个类type TSomeControl = class(TControl);//根类 TObjecttype TMyClass = class ... end;//等价于type TMyClass = class(TObject) ... end;
以上是小编为您精心准备的的内容,在的博客、问答、公众号、人物、课程等栏目也有的相关内容,欢迎继续使用右上角搜索按钮进行搜索class
, override
, type
, end
procedure
,以便于您获取更多的相关知识。
时间: 2024-09-13 16:36:46