传入动态数组

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;

阅读更多
个人分类: 指针函数 数组
上一篇数组类型指针
下一篇动态数组指针应用
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭