# Array of function pointers?

• 10-16-2001
The V.
Array of function pointers?
Ok, I'm a bit confused as to how to declare this.

I want to pass into one of my functions an array (of variable size) of function pointers. As it's variable size I assume I need to pass it as a pointer to the beginning of the array + count of elements.

Now, the syntax for declaring function pointers is already odd, so how do I declare this? Each function would take and return a double.

Would I declare my function like this:

void theFunction(double (**pfunc)()),int count)

And use it like this to call the first function (function #0):

double d = (*pfunc[0])(0.5);

??
• 10-16-2001
The V.
Figured it out :)

Figured I'd save myself some headache and do something like this:

typedef double (* FUNCPTR_DD)(double);

And then use:

theFunction(FUNCPTR_DD *, int);
• 10-16-2001
Troll_King
I sometimes get confused with the notation for passing an array of pointers:
//definition of instance
CAccount *array[size];
//call
array[0].Function(array,size);
//Declaration in class
viod Function(CAccount *[], int);
//definition of method
void CAccount::Function(CAccount *a[],int size){ ...}

It would be even more hellish to deal with an array of pointers to functions. This is where C/C++ ........es me off a little bit. I doubt that it has to be this confusing.
• 10-16-2001
The V.
The worst is actually trying to allocate the memory with new -- because it is confusing as hell as to where you put the *s and the []s.

That's why I do love that typedef -- you can define a pointer to a function with the params/returns you want as a new type, then use it like any other type.