I'm trying to pass a function pointer to another function, which has a string array as arguments. so far I have the following:
void pass_function(string args[]) {
//so something with args.
}
void takes_a_function(void(*function)(string[])) {
function;
}
int main()
{
string s[] = { "hello", "World" };
takes_a_function(pass_function(s));
system("pause");
return 0;
}
the issue appears to be that that the parameter pass_function(s)
is casting as a void
rather than void(*function)(sting *)
I'm imagining it requires a cast but would prefer a cleaner was of doing it if possible.
Aucun commentaire:
Enregistrer un commentaire