关闭

传入动态数组

613人阅读 评论(0) 收藏 举报
分类:
TMyRec = record
    sName: string[15];
    Sex: integer;
  end;

  pMyRec = ^TMyRec;
  arr1 = array of pMyRec;

var
  a1: arr1;
function method(T1: arr1): arr1;
begin
  Result := T1;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  i: integer;
begin
  SetLength(a1, 5);
  for i := Low(a1) to High(a1) do
  begin
    New(a1[i]);
    a1[i].sName := IntToStr(i);
    ShowMessage(method(a1)[i].sName);
  end;
end;

procedure TForm1.Button2Click(Sender: TObject);
var
  i: integer;
begin
  for i := High(a1) downto Low(a1) do
  begin
    ShowMessage(method(a1)[i].sName);
    Dispose(a1[i]);
  end;
end;

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:373247次
    • 积分:6075
    • 等级:
    • 排名:第4119名
    • 原创:215篇
    • 转载:126篇
    • 译文:1篇
    • 评论:43条
    最新评论