type
TMen=record
code:String;
name:String;
end;
TMenLst=array of TMen;
TForm10 = class(TForm)
Button1: TButton;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
a,b:TMenLst;
public
{ Public declarations }
procedure show(v:TMenLst);
end;
var
Form10: TForm10;
implementation
{$R *.dfm}
procedure TForm10.Button1Click(Sender: TObject);
begin
SetLength(a,3);
a[0].code:='code1';
a[0].name:='name1';
a[1].code:='code2';
a[1].name:='name2';
a[2].code:='code3';
a[2].name:='name3';
SetLength(b,3);
CopyMemory(@b,@a,SizeOf(a));
//Move(a, b, SizeOf(a));
a[0].code:='aaaa';
a[0].name:='bbbb';
show(a);
show(b);
end;
procedure TForm10.show(v: TMenLst);
var I:integer;
begin
for I := Low(v) to High(v) do
Memo1.Lines.Add('code:'+a[I].code+' '+'name:'+a[I].name);
Memo1.Lines.Add('---------------------');
end;
为什么修改一个变量会影响另一个