Hello,
I came across a strange pointer (in my opinion): void *(*foo)(int *);
Why are so many stars there? It was explained like:
"...read inside-out; notice that the innermost element of the expression is *foo, and that otherwise it looks like a normal function declaration. *foo should refer to a function that returns a void * and takes an int *. Consequently, foo is a pointer to just such a function."
So I understood that foo is a pointer to a void function f(int). I tried to code this but failed with error: invalid conversion from 'void (*)(int*)' to 'void* (*)(int*)' [-fpermissive]
void aFunction(int*)
{
cout << "something" << endl;
}
void f_voidFct()
{
void *(*voidPtr)(int *);
voidPtr=aFunction; // here I get the error
int a=5, *ptr_a=&a;
voidPtr(ptr_a);
}
What do I miss here? Can anyone explain this *(*ptr)(type*)
so I can get the idea?
Thanks!