In C, array subscription: a[b]
is merely the syntactic sugar equivalent of dereferencing after pointer arithmetic: *(a+b)
(as explained, say, here).
How is array subscription interpreted in C++, for base types? (Not for classes, for which we have overload semantics)? And, more specifically, what type does C++ expect to appear as the subscript? Is it a ptrdiff_t
?
C++ is exactly the same as C in this respect. C++11 §5.2.1: