I assume that "used as an array" means the subscript operator []
?
The reason is that in C and C++, the subscript operator actually performs pointer addition. It doesn't work on arrays at all, it causes the array name to decay to a pointer, and then pointer arithmetic occurs.
For all built-in types,
x[y]
is defined as
*(x + y)
It doesn't matter which of x
and y
is the pointer (or array decaying to pointer) and which is the offset.