The number of bytes allocated for each place in an array is
determined by the type of the objects to be stored. If an
array is to hold integers of type short
, for example, most
implementations of C++ would allocate 2 bytes per integer:
0 1 2 <-- Array | | | index v v v ------- ------- ------- --*---*---*---*---*---*---*---*---*- | | | | | | | | | -*---*---*---*---*---*---*---*---*-- ^ ^ ^ ^ | | | | 88 90 92 94
In this example, the first element of the array appears at memory address 88, the second appears at 90, and the third appears at 92.