Reading through Stroustrup C++ Programming Language I arrived at some rather strange array arithmetic (without use of pointers). He says the following:
QuoteFor every built-in array a and integer j within the range of a, we have:
a[j] == ∗(&a[0]+j) == ∗(a+j) == ∗(j+a) == j[a]
It usually surprises people to find that a[j]==j[a]. For example, 3["Texas"]=="Texas"[3]=='a'
This surprised me too. How 1. a[j]==j[a] and 2. 3["Texas"]=="Texas"[3]=='a' are possible?
Isn't a usually (read always) implicitly converted to T*, so how [a] could point to something meaning able? Also if array has 10 elements, than j==10, how address of 10 could point to the same thing, or it does?
If somebody could explain this through assembly or memory I would really appreciate it.