I've seen these two:
void (*foo)(int x);
Which is correct? Why use one over the other?
both are accepted in declaration, because in declaration you just need to specify the data type.
Though the both declaration are valid nevertheless including a name of a parameter has no any sense because this name is not used.
I like using one of these:
typedef void function_type(int) ;
function_type* foo = 0 ;
using function_type = void(int) // C++11 ;
function_type* foo = nullptr ;
Last edited on