K
Klaas Vantournhout
Hi all,
I'm in need of a matrix of function pointers, and to be honest. No
'nice' solution has been found yet on that big big internet.
It is possible to declare a matrix of function pointers in the following
way
void (*f[2][2])(int);
But I want to know how I can declare this only using double pointers.
like an array
double **a;
a = new double *[2];
for (int i = 0; i < 2; i++)
a = new double [2];
I would like to know this, because I have in my code something which is
similar like below, and i want it to work. The problem is, that during
compiling i obtain the following error.
cannot convert 'void (* (*)[2])(int)' to 'void (***)(int)' for argument
'1' to 'void pm_funcion(void (***)(int), int)'
cannot convert 'void (* (*)[3])(int)' to 'void (***)(int)' for argument
'1' to 'void pm_funcion(void (***)(int), int)'
thanks in advance
klaas
//function
void pm_function(void (***f) (int), int dim) {
for (int i = 0; i < dim; i++)
for (int j = 0; j < dim; j++)
f[j](5);
}
int main(void) {
void (*f[2][2])(int);
void (*g[3][3])(int);
// I want this to work, but it doesn not! See error above message
pm_function(f,2);
pm_function(g,3);
}
I'm in need of a matrix of function pointers, and to be honest. No
'nice' solution has been found yet on that big big internet.
It is possible to declare a matrix of function pointers in the following
way
void (*f[2][2])(int);
But I want to know how I can declare this only using double pointers.
like an array
double **a;
a = new double *[2];
for (int i = 0; i < 2; i++)
a = new double [2];
I would like to know this, because I have in my code something which is
similar like below, and i want it to work. The problem is, that during
compiling i obtain the following error.
cannot convert 'void (* (*)[2])(int)' to 'void (***)(int)' for argument
'1' to 'void pm_funcion(void (***)(int), int)'
cannot convert 'void (* (*)[3])(int)' to 'void (***)(int)' for argument
'1' to 'void pm_funcion(void (***)(int), int)'
thanks in advance
klaas
//function
void pm_function(void (***f) (int), int dim) {
for (int i = 0; i < dim; i++)
for (int j = 0; j < dim; j++)
f[j](5);
}
int main(void) {
void (*f[2][2])(int);
void (*g[3][3])(int);
// I want this to work, but it doesn not! See error above message
pm_function(f,2);
pm_function(g,3);
}