带有自定义初始化和最终化代码的记录
带有自定义初始化和最终化代码的记录
type TMyRecord = record Value: Integer; class operator Initialize(out Dest: TMyRecord); class operator Finalize(var Dest:TMyRecord); end; class operator TMyRecord.Finalize(var Dest: TMyRecord); begin Form1.Memo1.Lines.Add('destroyed ' + IntToHex(IntPtr(@Dest))); end; class operator TMyRecord.Initialize(out Dest: TMyRecord); begin Dest.Value := 10; Form1.Memo1.Lines.Add('created ' + IntToHex(IntPtr(@Dest))); end; procedure TForm1.Button1Click(Sender: TObject); begin var t: TMyRecord; Caption := t.Value.ToString; //10 end;
本文来自博客园,作者:{咏南中间件},转载请注明原文链接:https://www.cnblogs.com/hnxxcxg/p/19066831