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

Property   Найти похожие ветки 

← →
9899100   (2008-12-16 13:34) [0]

Подскажите плииз
запутался :)
есть класс
TMyClass=class
  fUse:Array[1..10] of Boolean;
 
  function ReadUse(Index:Integer):Boolean;
 
 public
   ....
  property Use[Index:Integer]:Boolean read ReadUse;
end;

Function TMyClass.ReadUse;
Begin
result:=fUse[Index];
End;

таким образом можно читать из этого свойства
а как должна выглядеть процедура записи
чтобы можно было в экземпляре класса
написать

ttt.Use[2]:=True;


← →
Сергей М. ©   (2008-12-16 13:38) [1]

property Use[Index:Integer]:Boolean read ReadUse write WriteUse;

Теперь ставишь курсор ввода на декларацию своего класса, жмешь CTRL-SHIFT-C и - о чудо ! - Делфи сама нарисовала все что тебе нужно)


← →
Ega23 ©   (2008-12-16 13:43) [2]

TMyClass=class
private
 fUse:Array[1..10] of Boolean;

 function GetItem(Index: Integer): Boolean;
 procedure SetItem(Index: Integer; const Value: Boolean);
public
 property Items[Index:Integer] : Boolean read GetItem write SetItem; default;
end;

function TMyClass.GetItem(Index: Integer): Boolean;
begin
 if (Index<Low(fUse)) or (Index>High(fUse)) then
   raise Exception.Create("Index out of bounds");
 Result :=  fUse[Index];
end;

procedure TMyClass.SetItem(Index: Integer; const Value: Boolean);
begin
 if (Index<Low(fUse)) or (Index>High(fUse)) then
   raise Exception.Create("Index out of bounds");
 fUse[Index] := Value;
end;


← →
9899100   (2008-12-16 13:43) [3]

>>Сергей М
шайтан

может она сама и все остальное напишет :))))))))))))


← →
9899100   (2008-12-16 13:45) [4]


> Ega23 ©


точно, спасибо, чейто я не подумал про проверку индекса на интервал



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

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



Память: 0.45 MB
Время: 0.008 c
3-1213899571
SuperChel
2008-06-19 22:19
2009.02.01
Запрос на SQL для выборки иерархического списка


3-1213861475
кот
2008-06-19 11:44
2009.02.01
не проходят запросы


15-1228571446
DillerXX
2008-12-06 16:50
2009.02.01
Про расчёт нагрузки на web-сайт


6-1198131456
vegarulez
2007-12-20 09:17
2009.02.01
ниид хелп, инстал инди 10, д6


3-1214206318
Matveih1
2008-06-23 11:31
2009.02.01
Как из Delphi завести нового пользователя в FireBird




   Наверх