msalters wrote:
Sergio wrote: If I have a private member:
void (*func)(void);
how can i declare a 'get' function that returns it? I tryed:
Don't try it this way, use a typedef.
typedef void(*fun_void_void)();
fun_void_void func;
fun_void_void GetFunc() { return func; }
Another option is to typedef the function type (rather than the
pointer-to-function). I only mention this because it hadn't
occurred to me that it was possible until recently, and I prefer
to avoid pointer typedefs if I can:
| typedef void (fun_void_void) ();
| fun_void_void func; // this declares a function
| fun_void_void *ptr_func = func;
| fun_void_void * GetFunc() { return ptr_func; }
or
| fun_void_void * GetFunc() { return func; }
because the name of a function is converted to a pointer to
that function, in a value context.