unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

type
  TRec = record               {定义结构 TRec}
    name: string[12];
    age: Word;
    function RecShow: string; {在结构中只能使用静态方法}
  end;

{ TRec 结构方法的实现}
function TRec.RecShow: string;
const
  str = '%s今年%d岁了';
begin
  Result := Format(str, [name,age]);
end;


//使用结构
procedure TForm1.Button1Click(Sender: TObject);
var
  rec: TRec;
begin
  rec.name := '张三';
  rec.age := 18;
  ShowMessage(rec.RecShow);
end;

end.