X
xgwzw
Unregistered / Unconfirmed
GUEST, unregistred user!
请问改怎么写才对啊,谢谢
type
mclass=class
private
x:TStrings;
y:Integer;
public
constructor create(flst:TStrings);
destructor Destroy
override;
end;
type
test1=class
private
fm:mclass;
z:Integer;
public
destructor Destroy
override;
constructor create(am:mclass);
procedure show;
end;
constructor mclass.create(flst: TStrings);
begin
flst:=TStringList.Create;
// flst.Add('A');
// flst.Add('B');
// flst.Add('C');
end;
destructor mclass.Destroy;
begin
Free(x);
inherited;
end;
{ test1 }
constructor test1.create(am: mclass);
begin
fm:=am;
end;
destructor test1.Destroy;
begin
FreeAndNil(fm);
inherited;
end;
procedure test1.show;
var
__i:Integer;
begin
for __i:=0 to fm.x.Count-1 do//出错
ShowMessage(fm.x.Strings[__i]);
end;
procedure TForm1.btn2Click(Sender: TObject);
var
x:mclass;
m:TStrings;
b1:test1;
begin
m:=TStringList.Create;
m.Add('1');
m.Add('2');
m.Add('3');
x:=mclass.create(m);
b1:=b1.create(x);
b1.show;//出错处
end;
type
mclass=class
private
x:TStrings;
y:Integer;
public
constructor create(flst:TStrings);
destructor Destroy
override;
end;
type
test1=class
private
fm:mclass;
z:Integer;
public
destructor Destroy
override;
constructor create(am:mclass);
procedure show;
end;
constructor mclass.create(flst: TStrings);
begin
flst:=TStringList.Create;
// flst.Add('A');
// flst.Add('B');
// flst.Add('C');
end;
destructor mclass.Destroy;
begin
Free(x);
inherited;
end;
{ test1 }
constructor test1.create(am: mclass);
begin
fm:=am;
end;
destructor test1.Destroy;
begin
FreeAndNil(fm);
inherited;
end;
procedure test1.show;
var
__i:Integer;
begin
for __i:=0 to fm.x.Count-1 do//出错
ShowMessage(fm.x.Strings[__i]);
end;
procedure TForm1.btn2Click(Sender: TObject);
var
x:mclass;
m:TStrings;
b1:test1;
begin
m:=TStringList.Create;
m.Add('1');
m.Add('2');
m.Add('3');
x:=mclass.create(m);
b1:=b1.create(x);
b1.show;//出错处
end;