クラス (TExample) があり、TExample メソッドを指すポインターの配列が必要です。たとえば、TExample.ThinkOne を使用して、aPointers[1] := @TExample.ThinkOne などを実行したいと考えています。どうすればこれを適切に行うことができますか?ありがとう。
2284 次
1 に答える
2
次のようなことができます。
type
TProcType = procedure(const AParm: Integer) of object; // Method type
TProcArray = array of TProcType; // Dynamic array
TExample = class
public
procedure A(const AParm: Integer); // Method signature matches TProcType
procedure B(const AParm: Integer);
end;
var
pa : TProcArray;
procedure Init(const AExample: TExample);
begin
SetLength(pa, 2);
pa[0] := AExample.A;
pa[1] := AExample.B;
end;
于 2010-09-25T18:53:44.510 に答える