C++ syntax inherited from C is weird, counterintuitive and archaic. You need the typefef to cope with the fact.
int (*retFun())(int) { ... }
is frankly an unreadable mess.
The new crop of the C++ syntax alleviates the problem somewhat.
auto retFun () -> auto (*)(int) -> int {
return [](int x) { return x; };
}
The new syntax is written mostly left-to-right, as one would read it.
auto retFun
"retFun is ..."
() ->
"... a function that takes no arguments and returns ..."
auto (*)
"... a pointer to ..."
(int) ->
"... a function that takes an int argument and returns ..."
int
"... an int".
More about function declarations.