C++ Array Indexing

Array indexing in C++ behaves like pointer arithmetic. In addition to referencing element i of array a as a[i], C++ also allows you to reference the same element as i[a]. This is due because (like C) arrays act like pointers to blocks of memory, so a[i] = *(a + i) = *(i + a) = i[a].



PISIKA Copyright © 2009