Array of function pointers

Hello. For my program, I need to write an array of function pointers which return the same data type but have diffrent paramaters. My idea was to create a typedef of a function pointer and make an array of them, like this:
1
2
3
typedef double*(function_pointer)(double);
function_pointer fp_arrayOfFunctionPointers[52]
...
But obviosuly that only works with functions that take one double as a paramater and will not work for all my functions. So is it possible to have on array with diffrent types of function pointer or will that not work?
Last edited on
Two ideas come to my mind:

1. Make the functions take a void pointer and the void pointer can point to different structures with the types you specify. Just cast the void pointer to the structure:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

function_pointer fp_arrayOfFunction Pointers[ ( void * )p ];

struct
    {
    double d;

     }
         double_struct;

struct
    {
    int i;

    }
        int_struct;


2. Make the function signature a varaible argument list like printf()
Topic archived. No new replies allowed.