What Is an Array?

An array is a collection of objects, all of the same type. An array can be envisioned as a series of data storage locations; each storage location is called an element of the array.

You declare an array by writing the type, followed by the array name, a left brace, the subscript, and a right brace. The subscript is the number of elements in the array surrounded by square brackets. For example,

long LongArray[25];

declares an array of 25 long integers, named LongArray. When the compiler sees this declaration, it sets aside enough ...

Get Sams Teach Yourself C++ in 24 Hours, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.