uses System.Math;
type
TPowerOfTwo = class
private
function GetItem(I: Integer): Integer;
public
//default: the object itself is
//indexable with []
property Items[I: Integer]: Integer
read GetItem; default;
end;
function TPowerOfTwo.GetItem(
I: Integer): Integer;
begin
Result := Round(Power(2, I));
end;
var
Power2: TPowerOfTwo;
begin
Power2 := TPowerOfTwo.Create;
WriteLn('p2 is ', Power2[2]);
//p2 is 4
WriteLn('p8 is ', Power2[8]);
//p8 is 256
WriteLn('p16 is ', Power2[16]);
//p16 is 65536
end.