T
TYZhang
Unregistered / Unconfirmed
GUEST, unregistred user!
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
Ttest = class
public
name: string[20];
end;
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
list:tlist;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
begin
list:=tlist.Create;
end;
procedure TForm1.Button1Click(Sender: TObject);
var jtest : Ttest;
i:integer;
begin
for i:=0 to 3 do
begin
jtest:= Ttest.Create;
list.add(pointer(jtest));
jtest.name:='xxx'+inttostr(i);
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
showmessage(ttest(list[0]).name);
end;
end.
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
Ttest = class
public
name: string[20];
end;
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
list:tlist;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
begin
list:=tlist.Create;
end;
procedure TForm1.Button1Click(Sender: TObject);
var jtest : Ttest;
i:integer;
begin
for i:=0 to 3 do
begin
jtest:= Ttest.Create;
list.add(pointer(jtest));
jtest.name:='xxx'+inttostr(i);
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
showmessage(ttest(list[0]).name);
end;
end.