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

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

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -