Array syntax

As with most programming languages, in C++ several variables of the same type can be combined into an array. The elements of the array are accessed via an index. The type of the elements and the size of the array must be specified in the definition.

Declare Array

int myArray[] = {};
double anotherArray[5];

Initialize Array

int myArray[] = {2, 6, 4, 8, 1};

cout << myArray[2] << endl;