Вниз
Скачать: CL | DM;

Очередная несложная разминка для начинающих ;)   Найти похожие ветки 

 
MBo ©   (2002-05-24 12:03) [0]

Найти ошибку в реализации класса списка целых чисел
Предложить методы исправления.


TIntList=class(TList)
private
procedure SetInt(Index:Integer;Value:Integer);
function GetInt(Index:Integer):Integer;
public
property Items [index:Integer]:Integer read GetInt write SetInt; default;
procedure Add(Value:Integer);
end;

implementation

procedure TIntList.SetInt(Index:Integer;Value:Integer);
begin
inherited Items[Index]:=@Value;
end;

function TIntList.GetInt(Index: Integer): Integer;
begin
Result:=PInteger(inherited Items[Index])^;
end;

procedure TIntList.Add(Value:Integer);
begin
inherited Add( @Value);
end;



 
Виктор Щербаков ©   (2002-05-24 12:07) [1]

:-)))


 
MBo ©   (2002-05-24 12:12) [2]

>Виктор Щербаков
Реально встретилось, там еще кое-что было ;)


 
Alx2 ©   (2002-05-24 12:17) [3]

@Value - адрес в стэке :)


 
Кулюкин Олег ©   (2002-05-24 12:20) [4]

:))))))


 
MBo ©   (2002-05-24 12:23) [5]

>Alx2
на самом деле SetInt так и было, а Add так:
procedure TIntList.Add( VAR Value:Integer);


 
Alx2 ©   (2002-05-24 12:37) [6]

Борис, откуда выкопал этот "смелый" подход?


 
MBo ©   (2002-05-24 12:50) [7]

>Alx2
Спросили, почему компилируется, но не вполне работает ;)


 
Tonie ©   (2002-05-24 13:17) [8]

Класс %)))))



Страницы: 1 вся ветка

Скачать: CL | DM;



Память: 0.46 MB
Время: 0.008 c
3-88696
sergikkkk
2002-06-01 11:50
2002.06.27
interbase


3-88737
harismatik
2002-06-04 11:29
2002.06.27
Вопрос по DBGrid


3-88726
pilot
2002-06-04 09:35
2002.06.27
OnValiadate


1-88952
Иван
2002-06-14 23:38
2002.06.27
Wrapper на ActiveX делает нехорошие вещи


6-88974
Donal_Graeme
2002-04-10 18:09
2002.06.27
TClientSocket в TThread не работает...




   Наверх