how to do member function pointer in D?

u e at mail.com
Wed Jul 30 22:34:26 PDT 2008


> I'm not sure I completely understand either but I'll take a stab.  What
> about using polymorphism?  Where delegates can be any type of object
> interfaces restrict what sort of objects can be used with your hash-table.

Go back to my original question:

How to create a variable which hold a particular function pointer of a class, and
can be invoked on different objects of that class:

fp = &(A.f);
A a1, a2;
a1.fp();   // how to make this invocation work?
a2.fp();

And I have one more requirement that even if A.f() and A.g() have same signature,

fp = &(A.g);   // expect compiler report error here.

How to declare the type of such fp?



More information about the Digitalmars-d mailing list