Reputation: 81
void printFunc( void(*)(int&,int&), int& );
I don't know what this code does. I know it's a function prototype with two parameters, but I don't know what the first parameter means.
Upvotes: 0
Views: 151
Reputation: 171107
It's a pointer to a function which takes two int&
parameters and returns void
.
If there was an identifier for it (let's say p
), it would be spelled like this:
void (*p)(int&, int&)
Then, we can apply the principle "if we type the declaration as an expression, we get its type." So:
(*p)
means p
is a pointer
(*p)(int&, int&)
means (*p)
is a function taking two int&
parameters
void (*p)(int&, int&)
means it returns void
.
Upvotes: 0
Reputation: 110648
The first parameter type is a pointer to a function that takes two arguments, both int&
s, and returns void
.
void foo(int&, int&);
If you have this function declaration, you could pass foo
as an argument to printFunc
.
Upvotes: 2