q
and &a
are pointers to an array.
*q
and a
are an "array". But you cannot pass an array to a function (and std::ostream::operator<<
is a function); you really pass a pointer to the first element that is created implicitly (called pointer decomposition). Thus, *q
and a
become pointers to the first element of the array.
The beginning of the array is in the same place in memory as the array is trivial. Since none of the pointers is a-to-char pointer (which is handled specifically to make string literals work as expected), the addresses are simply printed.
source share