-1
インスタンスtotoという名前のプロパティを持つクラスを実装したいのですが、tlistのように追加、読み込み、書き込みができる動的配列です。それが正しいD6の中で一重の動的配列を持つクラスの最短実装は何ですか?
Tmodel = Class(TObject)
ftoto:array of single;
function gettoto(ind : integer):single
function gettotosize:integer;
procedure settoto(ind : integer;valeur:single);
property toto[ind:integer]:single read gettoto write settoto;
property totosize:integer read gettotosize;
end;
function Tmodel.gettoto(ind : integer):single;
begin
result:=ftoto[ind];
end;
procedure Tmodel.settoto(ind : integer;valeur:single);
begin
setlength(ftoto,ind+1);
ftoto[ind]:=valeur;
end;
function Tmodel.gettotosize:integer;
begin
result:=length(ftoto);
end;
です: 私はこれを書きましたか?
デストラクタはどうですか?私はリークを避けるために自由奔放を加えるべきですか? – bbd
推測の代わりに、動的配列が管理されていることを伝える文書を読んでください。 –
DHは常に否定的で役に立たないコメントであるので、私の投稿に答えることはできません。事前の知識 – bbd