ShriramS
asked on
Array of function pointers
Is it possible to create an array of function pointers and if so how ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
That depends on when you know how may pointer you need. If you know it at constructor time, you can create a pointer to an array of pointers and allocate the memory at constructor time for just the number of elements you need.
void (**pfa)(char*);
void xyz(char *x)
{}
X:x(int n) {
pfa = new (void (*[n])(char *));
pfa[0] = xyz;
}
pfa[0]("hello");
If you want real dynamic array, you need to use the vector class from the Standard Library.
void (**pfa)(char*);
void xyz(char *x)
{}
X:x(int n) {
pfa = new (void (*[n])(char *));
pfa[0] = xyz;
}
pfa[0]("hello");
If you want real dynamic array, you need to use the vector class from the Standard Library.
ASKER
Thank You
ASKER