How to declare an array of pointers to functions returning different types?
|
1 answer
The array is an array, indicating one type and no matter int char or int (*)(void) . But you can create an array of pointers to one type of function, and when called, specify another type
int fun_0(int); int fun_1(int,int); int fun_2(int,int,int); int (*array_fun[])(int) = {fin_0,(int (*)(int))fin_1,(int (*)(int))fun_2}; int (*fun)(int,int) = (int (*)(int,int))array_fun[1]; *fun(3,5); |
void*, where the pointer will be stored. - KoVadim