Arrays are arguably the most common and fundamental programming data structure. FORTRAN, the first high-level programming language, included them, and all contemporary general-purpose programming languages support them in some form. Although programs often use them without further embellishment, they also form the foundation for more complex structures like strings, stacks, vectors, matrices, etc. Given their widespread application, we must understand how to create and use them correctly.
Know
How to define an array
The number of dimensions (each dimension is enclosed in a separate set of square brackets)
The size of each dimension
Be able to define an array as an automatic or local variable on the stack (dimension sizes must be compile-time constants)
Be able to define an array as a dynamic variable on the heap with the new operator (with some restrictions, dimension sizes may be constants or variables)
Each individually addressable component of an array is called an element
How to access the elements of an array
Array elements are selected by one or more indexes, one for each dimension
Each array index is enclosed in a separate set of square brackets
C++ arrays are zero-indexed: valid array indexes are 0 ≤ index < array-size - 1
How to write secure code that prevents buffer overrun or overflow errors