C++

Arrays

To declare an array, write the type of object stored, followed by the name of the array and a subscript with the number of objects to be held in the array. 

Example 1

int MyIntegerArray[90];

Example 2

long * ArrayOfPointersToLongs[100];

To access members of the array, use the subscript operator. 

Example 1

int theNinethInteger = MyIntegerArray[8];

Example 2

long * pLong = ArrayOfPointersToLongs[8]

Arrays count from zero. An array of n items is numbered from 0 to n-1.

Back to Index