Start with the leftmost identifier and work your way out, remembering that ()
and []
bind before *
, so:
T *a[N] // a is an array of pointer to T
T (*a)[N] // a is a pointer to an array of T
T *f() // f is a function returning pointer to T
T (*f)() // f is a pointer to a function returning T
Edit
Although it doesn’t show up in this declaration, const
can introduce its own share of wrinkles:
T const *p // p is a pointer to constant T
const T *p // same as above
In both of these cases, p
points to a constant T
. You can write to p
(make it point to a different object), but you cannot write to *p
(you cannot update the value of the thing p
points to).
T * const p // p is a constant pointer to T
This declares p
as a constant pointer to T
; You can write to *p
(update the value of the thing p
points to, assuming *p
results in a modifiable lvalue), but you cannot write to p
(you can’t make it point to a different object).
End edit
So
var -- var is a
var[3] -- 3-element array of
*var[3] -- pointer to
(*var[3])() -- function taking
(*var[3])() -- unspecified parameters
*(*var[3])() -- returning pointer to
(*(*var[3])())( ) -- function taking
(*(*var[3])())( ) -- unnamed parameter is a
(*(*var[3])())( * ) -- pointer to
(*(*var[3])())( (*)()) -- function taking
(*(*var[3])())( (*)()) -- unspecified parameters
(*(*var[3])())(void (*)()) -- returning void
int (*(*var[3])())(void (*)()); -- returning int
So, var
is a 3-element array of pointers to functions, each of which returns a pointer to another function (which takes a pointer to yet another function as an argument) that returns int
.
3
solved Describe: int (*(*var[3])())(void (*)());