With pointer and reference declarations, you just read from right to left:
ptr
is a pointer to a pointer to a pointer to a pointer to a const
pointer to a pointer to a pointer to a pointer to a const volatile
pointer to a pointer to a const
pointer to a const
object of unknown type.
If you follow the guideline of putting any const
or volatile
qualifiers after the first type specifier (i.e. void const *
) rather then before it (i.e const void *
), then you can read consistently from right to left; otherwise, you sometimes have a slight hiccough when you reach the left-hand end.
The spiral "rule" is occasionally useful for declarations involving arrays or functions, where the name being declared isn't the last thing in the declaration. In this case, with nothing after the name, it degenerates to reading right-to-left.