Уважаемые форумчане.
Вот мой класс (заготовка). Класс будет работать с динамическим массивом
Код:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | 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.
Как исправить ошибку, не меняя определения функции, или не получится?