Уважаемые форумчане.
Вот мой класс (заготовка). Класс будет работать с динамическим массивом
Код:
unit U_Event;
interface
type
TEvent = record
F_1 : string;
F_2 : integer;
F_3 : string;
end;
type
TEventList = class(TObject)
private
fCount: integer;
fItemIndex: integer;
function GetCount :integer;
function SetCount(NewCount: integer): boolean;
public
items : array of TEvent;
constructor Create;
property Count : integer read GetCount Write SetCount;
destructor free; virtual;
end;
implementation
// Конструктор
constructor TEventList.Create;
begin
inherited;
fItemIndex := -1;
fCount := 0;
SetLength(items,fCount);
end;
// Изменение размеров массива событий
function TEventList.SetCount(NewCount: integer): boolean;
begin
Result := True;
if NewCount < 0 then
begin
Result := False;
NewCount := 0;
end;
fCount := NewCount;
SetLength(items,fCount);
end;
// Чтение размера массива событий
function TEventList.GetCount: integer;
begin
result := fCount;
end;
// Разрушение объекта
destructor TEventList.free;
begin
SetLength(items,0);
Inherited Destroy;
end;
end.
Ошибка в строке 23. Говорит о несовместимости типов. Скорее всего из-за того, что тип функции SetCount - Boolean а тип Count - integer.
Как исправить ошибку, не меняя определения функции, или не получится?