You are here

Overview

10 February, 2015 - 16:16

An array is a sequenced collection of elements of the same data type with a single identifier name. As such, the array data type belongs to the "Complex" category or family of data types. Arrays can have multiple axes (more than one axis). Each axis is a dimension. Thus a single dimension array is also known as a list. A two dimension array is commonly known as a table (a spreadsheet like Excel is a two dimension array). In real life there are occasions to have data organized into multiple dimensioned arrays. Consider a theater ticket with section, row and seat (three dimensions). This module will only cover the single dimension array. Most single dimension arrays are visualized vertically and are often called a list.

Most programmers are familiar with a special type of array called a string. Strings are basically a single dimension array of characters. Unlike other single dimension arrays, we usually envision a string as a horizontal stream of characters and not vertically as a list. Within C++ the string data type is a length-controlled array and is a pre-defined data class.

We refer to the individual values as members (or elements) of the array. Programming languages implement the details of arrays differently. Because there is only one identifier name assigned to the array, we have operators that allow us to reference or access the individual members of an array. The operator commonly associated with referencing array members is the index operator. It is important to learn how to define an array and initialize its members. Additionally, the sizeof operator is often used to calculate the number of members in an array.