Type
pRecData = ^TRecData;
tRecData = record
Caption: string[15];
Level: Integer;
end;
myCls = class
private
fMyrec: pRecData;
public
function Test: string; virtual;
constructor create;
destructor destroy; override;
property myrec: pRecData read fmyrec write fmyrec;
end;
constructor mycls.create;
begin
New(Fmyrec);
end;
destructor mycls.destroy;
begin
Dispose(Fmyrec);
end;
function mycls.Test: string;
begin
fMyrec.Caption := '被始化字符串'; //直接写入Fmyrec成员变量
ShowMessage(Fmyrec.Caption); //直接读取Fmyrec成员变量
Result := 'true';
end;
{实例化}
var
iCls: myCls;
begin
iCls := myCls.Create;
iCls.Test;
iCls.myrec.Caption := 'update Myrec'; //更新Rrec数据
iCls.myrec.Level := 255;
ShowMessage(iCls.myrec.Caption);
FreeAndNil(iCls);
end;
初写类
最新推荐文章于 2022-08-28 15:05:49 发布