Reputation: 3
If I want an array of pointers to something, I declare it like this:
Type** var = new Type*[8];
and use it like this:
if(var[0] != NULL)
// Do something
But how can I have an array of function pointers in a similar fashion? Something like this maybe:
typedef bool (*Handler)(int, int);
Handler** list = new Handler*[8];
...
Handler* func = list[0];
if(func != NULL)
*func(6, 5);
Upvotes: 0
Views: 185
Reputation: 444
You would have:
typedef bool (*Handler)(int, int);
Handler* list = new Handler[8];
Handler func = list[0];
if (func != NULL)
func(6, 5);
Just don't put an extra *
Upvotes: 2