构造的问题
typeTPerson = class
public
Name:string;
Age:Integer;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
consen:Tperson;
begin
consen:=Tperson.create;
consen.Name:='小珊';
consen.Age:=25;
showmessage(consen.Name);
showmessage(inttostr(consen.Age));
consen.Free;
end;
//***************************************************//
tpye
TPerson=object
public
Name:string;
Age:integer;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
consen:Tperson;
begin
consen.Name:='小珊';
consen.Age:=25;
showmessage(consen.Name);
showmessage(inttostr(consen.Age));
end;
两者有什么区别吗?第一种不用consen:=Tperson.create;也可以操作对象成员.