Introducing Arrays
An array is a data form that can hold several values all of one type. For example, an array can hold 60 type int values that represent five years of game sales data, 12 short values that represent the number of days in each month, or 365 float values that indicate your food expenses for each day of the year. Each value is stored in a separate array element, and the computer stores all the elements of an array consecutively in memory.
To create an array, you use a declaration statement. An array declaration should indicate three things:
The type of value to be stored in each element
The name of the array
The number of elements in the array
You accomplish this in C++ by modifying the declaration for a simple variable, adding brackets ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access