function pointer error

i keep getting the error " expression must be a complete object type" at the line where it says "out[i] = algo[a][in[i]];" i do not know why do to not working with pointers much

typedef int(*algorithms) (int a);

//start algorithms (put algorithms here)
int algo1(int a) {


return a;
}

int algo2(int a) {


return a;
}

int algo3(int a) {


return a;
}
//end algorithms

// points to algorithms
algorithms algo[] = {
algo1,
algo2,
algo3
};

void procces(int a) {
for (int i = 0; i < sizeof(in) / sizeof(in[0]); i++ ) {
if (in[i] != -1) {
//proccesing algorithm
out[i] = algo[a][in[i]];
//proccesing algorithm
}
else {
out[i] = in[i];
}
};
Sleep(100);
for (int i = 0; i < sizeof(out) / sizeof(out[0]); i++) {
if (out[i] == NULL) {
out[i] = -1;
}
}
}
Last edited on
1
2
3
4
5
6
7
out[i] = algo[a][in[i]];
// error: invalid conversion from 'algorithms {aka int (*)(int)}' to 'int'

out[i] = algo[a];
// error: invalid conversion from 'algorithms {aka int (*)(int)}' to 'int'

out[i] = algo[a]( 42 ); // looks like a valid function call 
Last edited on
Thanks I'll try it see what happens
Topic archived. No new replies allowed.