user600003
user600003

Reputation: 3

Array of function pointer pointers

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

Answers (1)

SeedmanJ
SeedmanJ

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

Related Questions