Feb 20, 2013 at 10:56am UTC
Last edited on Feb 20, 2013 at 10:56am UTC
Feb 20, 2013 at 11:41am UTC
Ok, I understand all that, but how do I go about making the array a member of the class? Where do I define it and how? Can it be on the stack? If so, how?
Also, as my function is declared and defined within the class, I don't need to prepend the "A::" part to "funarr" right?
Last edited on Feb 20, 2013 at 11:47am UTC
Feb 20, 2013 at 12:33pm UTC
JLBorges; I get the error "a class-qualified name is required" when I run this line:
using mem_fun_ptr_t = decltype ( &Baseop::fun1 ) ;
Feb 20, 2013 at 10:06pm UTC
Ah yes, sorry about that. The equivalent to your code would have been:
using mem_fun_ptr_t = decltype ( &A::fun1 ) ;
Feb 20, 2013 at 10:26pm UTC
EDIT: Thanks JLBorges, I seem to have got it working using the following, based on your suggestions:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
Class A
{
public :
void fun1() {}
void fun2() {}
void fun3() {}
void fun4() {}
typedef void (A::*mem_fun_ptr_t)();
static const mem_fun_ptr_t funarr[]; // array of function pointers
}
// define the array
const A::mem_fun_ptr_t A::funarr[] =
{
&fun1,
&fun2,
&fun3,
&fun4
};
Cheers
Last edited on Feb 20, 2013 at 11:13pm UTC