delphi - Array of procedures inside a class pointing to class method -


i have class (texample) , want have array of pointers point texample methods. example, i'd have texample.thinkone , apointers[1] := @texample.thinkone or similar. how can this? thanks.

you can this:

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;       

Comments

Popular posts from this blog

ruby - When to use an ORM (Sequel, Datamapper, AR, etc.) vs. pure SQL for querying -

php - PHPDoc: @return void necessary? -

c++ - Convert big endian to little endian when reading from a binary file -