Hello Ben!
BC> is it possible to pass member functions as arguments to
BC> other functions?
BC> I have a class called display which has a member function:
BC> void xGathercb(FL_OBJECT *, long);
BC> I need to pass this function as an argument of another function:
BC> fl_set_object_callback(FL_OBJECT *, xGathercb, long);
I assume that this second function is not a class member function? If so,
the only member function that you can safely pass to it is one declared as a
static member.
The reason is that non static member functions have an extra parameter in
their calling list; the pointer to the associated object. The compiler is
telling you that if you cast it from a non-static member function to a
non-member function with a similar looking parameter list, the compiler
doesn't know what to do about assigning a value for the object pointer.
The problem is similar to declaring a function prototype of
int foo(long* first, short second, bool third);
and then trying to implement it as
int foo(short second, bool third)
{
'''
}
BC> So it is possible to cast from:
BC> void (display::*)(blah)
BC> to
BC> void (*)(blah)
It is possible (casts always work) but it wont get the result that you want.
-Ron (ron-bass@ti.com)
--- EZPoint V2.2
---------------
* Origin: There's a point here, somewhere... (1:128/13.3)
|