10.
float (*abc)(float (*def)(float *ghi));
This one is really complicated. Adding in the parentheses only
makes it seem worse:
float ((*abc)(float ((*def)(float *ghi))));
What is being declared? abc, def, or ghi?
Its not always easy to tell; a good rule of thumb is to go for the
first name you meet, and see if it makes sense. So:
- abc is being declared,
- it is a pointer to something,
- the something is a function. We can see that the function returns
a float, but what is its parameter supposed to be? Analyse it separately.
The parameter was declared float ((*def)(float *ghi)) which
you might recognise from before:
- def is being declared,
- it is a pointer to something,
- the something is a function,
- the function takes a float * parameter,
- and returns a float
So, the whole thing, abc, being declared is just a simple variable.
It can store a pointer to a function. But the function that it can point to
is one that takes other functions as its parameter, and returns a float
as its result.
I suppose we could describe the type of abc like this:
ABC is:- A pointer to
- a function
- whose parameter is
- a function whose parameter is
- a pointer to a float
- and whose result is a float
- and whose result is a float
Don't worry, nothing this complex will appear on the test.