function pointer declaration syntax

divine fallacy (34)
I've seen these two:

void (*foo)(int);

and

void (*foo)(int x);

Which is correct? Why use one over the other?
noisycoder (49)
both are accepted in declaration, because in declaration you just need to specify the data type.
vlad from moscow (3661)
Though the both declaration are valid nevertheless including a name of a parameter has no any sense because this name is not used.
JLBorges (1754)
I like using one of these:

1
2
typedef void function_type(int) ;
function_type* foo = 0 ;


1
2
using function_type = void(int) // C++11 ;
function_type* foo = nullptr ; 
Last edited on
Registered users can post here. Sign in or register to post.