In C++, arrays allow you to store multiple values of the same type under a single variable name. An array declaration specifies the type of elements it will hold and the number of elements it can contain.
When declaring an array, you need to provide the data type, the name of the array, and the size. For example, if you want to declare an array that can store 100 integers, you would use:
This declaration creates an integer array called `myArray`, capable of storing 100 integer values.
When working with arrays of custom data types, such as structs, the same principles apply. You define the array using the struct type as the data type. This allows each element of the array to be a struct, containing multiple fields.
For instance, in the given exercise, an array `inventory` of type `partsType` is declared to store 100 elements of the struct, each capable of holding a part's name, number, price, and stock quantity:
- `partsType inventory[100];`
This means that `inventory` can hold 100 entries, each with its own set of properties described by the `partsType` struct.