You need to learn to read declarations. It will help a lot.
Start with the name (can you identify the name here? It's "oper_lut"),
then look to the *right*. If there is no bracket, you then proceed to
the *left*. If there is a bracket, you proceed to say "is an array", so
you get so far
oper_lut ...(to the right there is a bracket) ... is an array of
(how many elements? we don't know, the bracket closes before the size
is specified) ... unknown size ... of (continue to the right, there is
an equal sign, which means there is an initializer, which is not part of
the declaration, so we reverse the direction)... "struct oper".
Anything else? Nothing. So, what did we get?
'oper_lut' is an array of unknown size of 'struct oper'.
A better approach can be found on the web, I've seen it, and I am sure
you can find it. Look for "how to read C++ declarations"
> 2) What is this:
> double (*get_oper(int oper_type))(double)
Same approach. Can you find the name? is 'oper_type' the name of the
object being declared? Hint: no. What else can be a name? Hint: it's
actually 'get_oper'. So you look to its *right*, you don't see a
bracket, so (it's not an array) you reverse the direction. You see the
asterisk. It's _a_pointer_ ! To what? Keep going... Drat, a closing
(if going in that direction) parenthesis. Revers the direction. An
opening parenthesis, followed by a declaration. An argument list! So,
we say "a function that takes {all embedded declarations go here}" and
keep naming those until we find a closing parenthesis, which is very
close. What did we get so far?
" 'get_oper' (to the left)... is a pointer (reverse the direction) ...
to a function that takes one argument of type int"
Now, we need to know what that function with one int argument returns,
right? So we keep going in the same direction (which was to the right).
Drat, another opening parenthesis. What does a parenthesis say?
Depends on what's inside. And inside is a declaration (it's a bare
type), so we add "a function that takes". What follows? The argument
list -- "a double". Closing parenthesis means we keep going, but we see
it's the end of the declaration. So we reverse direction to say "and
returns"... What's left? The return type -- "a double".
That is, we get
"'get_oper' is a pointer to a function that takes one int and returns a
function that takes a double and returns a double."
That's not easy. You'll get the hang of it eventually, though.
Since a function cannot be returned, a function that returns a function
simply returns a _pointer_ to a function.
V
--
I do not respond to top-posted replies, please don't ask