This question is motivated by the post C++: class that has a pointer to a function as an attribute
I came up with a similar problem that the one described in there. And it is the way on how to correctly declare a function pointer. This seems pretty usefull for me, as you can declare a function pointer and then assign it later to make the program much more general. The three ways that are described in the post are the following ones:
- The first case is obviously wrong, it declares a function that returns a void pointer
void* func()
. - The way upvoted and tagged as solution. It does not work for my particular case
void *(func)()
. This case seems to be the same as the previous one. - The third comment and the one working for me
void (*func)()
. This seems clear to me that the definition is a pointer to a void function.
My question is summarized as: What is the main difference between the second and third declaration?