In complement with @Vittorio answer, there is the Clockwise Spiral Rule to help us decypher complex types:
Starting with the unknown element, move in a spiral/clockwise direction; when encountering the following elements replace them with the corresponding English statements:
[X]
or []
Array X
size of... or Array undefined size of...
(type1, type2)
Function passing type1 and type2 returning...
*
pointer(s) to...
Keep doing this in a spiral/clockwise direction until all tokens have been covered. Always resolve anything in parenthesis first!
Here:
+-----------+
| +------+ |
| | >-v | |
temp (*(*foo())())()
| | ^---+ | |
| ^--------+ |
+--------------+
foo
is a function returning a pointer to a function returning a pointer to a function returning a temp
.
And now, @UKmonkey just renamed this rule The C++ Guru Snail Rule or CGSR for short:
/ /
L_L_
/ \
|00 | _______
|_/ | / ___ \
| | / / \ \
| |_____\ \_ / /
\ \____/ /_____
\ _______________/______\.............................