use non-static member function as the objective function

Martin MacRobert martin at mediavillage.org.au
Mon Apr 23 21:39:38 EDT 2001


Yes you can. You can smuggle the address of a function pointer using a typedef.

eg.

 typedef  BOOL ( *_DoFill)(HDC hdc);
 _DoFill GradientFill;

GradientFill is a function pointer of type _DoFill.
You can pass GradientFill as a pointer to function. As long as you cast the
userdata to type _DoFill, you can invoke the function. The same holds true for
member functions as well. You should check a C++ text on using function
pointers for more detail.

Martin


Wu Ruoyun wrote:

> Dear Martin:
>
> Thank you very much for your reply.  However, I am afraid that "smuggling"
> the address of an object is not the same as "smuggling" the address of a
> function.  In my case, a non-static function can't be cast to a
> GAGenome::Evaluator.
>
> Best Wishes!
> Ruoyun
>






More information about the galib mailing list