- Код: Выделить всё
{ TMuClass }
PMuClass = ^TMuClass;
TMuClass = class
private
FActive: boolean;
FCount: integer;
procedure SetActive(AValue: boolean);
procedure SetCount(AValue: integer);
public
property Active:boolean read FActive write SetActive;
property Count : integer read FCount write SetCount;
constructor Create;
destructor Destroy;override;
end;
var
Form1: TForm1;
List : TList;
implementation
{$R *.lfm}
{ TMuClass }
procedure TMuClass.SetActive(AValue: boolean);
begin
if FActive=AValue then Exit;
FActive:=AValue;
end;
procedure TMuClass.SetCount(AValue: integer);
begin
if FCount=AValue then Exit;
FCount:=AValue;
end;
constructor TMuClass.Create;
begin
FActive:=false;
end;
destructor TMuClass.Destroy;
begin
end;
{ TForm1 }
procedure TForm1.FormCreate(Sender: TObject);
begin
List:=TList.Create;
end;
procedure TForm1.btAddClick(Sender: TObject);
var index:integer;
begin
index:=List.Add(TMuClass.Create);
TMuClass(List[index]).Count:=index;
end;
procedure TForm1.btGet0pointClick(Sender: TObject);
var pClass : PMuClass;
begin
pClass:=List[SpinEdit1.Value];
Edit1.Text:=inttostr(pClass^.Count);
end;
То есть если я добавил в TList объект класса, то он хранит ссылку на него. Но я получаю по ссылке фигню. Где я ошибаюсь?