function pointer declaration syntax

Jan 1, 2013 at 11:04pm
I've seen these two:

void (*foo)(int);

and

void (*foo)(int x);

Which is correct? Why use one over the other?
Jan 1, 2013 at 11:08pm
both are accepted in declaration, because in declaration you just need to specify the data type.
Jan 2, 2013 at 1:00am
Though the both declaration are valid nevertheless including a name of a parameter has no any sense because this name is not used.
Jan 2, 2013 at 3:40am
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 Jan 2, 2013 at 3:54am
Topic archived. No new replies allowed.