|
|
|
|
|
|
|
3. C++ does not allow aggregate operations on arrays. There is no aggregate assignment, aggregate comparison, aggregate I/O, or aggregate arithmetic. You must write code to do all of these operations, one array element at a time. |
|
|
|
|
|
|
|
|
4. Omitting the size of an array in its declaration is permitted only in two cases: (1) when an array is declared as a formal parameter and (2) when an array is initialized in its declaration. In all other declarations, you must specify the size of the array with a constant integer expression. |
|
|
|
|
|
|
|
|
5. If an array parameter is incoming-only, declare the formal parameter as const to prevent the function from modifying the parameter accidentally. |
|
|
|
|
|
|
|
|
6. Don't pass an individual array component as an actual parameter when the function expects to receive the base address of an entire array. |
|
|
|
|
|
|
|
|
7. The size of an array is determined at compile time, but its actual length is determined at run time. This means that an array must be declared to be as large as it could ever be for the particular problem. Subarray processing is used to process only the components that have data in them. |
|
|
|
|
|
|
|
|
8. Pass the length as well as the name of the array to functions when subarray processing is to take place. |
|
|
|
|
|
|
|
|
In addition to being able to create user-defined atomic data types, we can create structured data types. In a structured data type, a name is given to a group of components that have a specific arrangement. With many structured types, the group can be accessed as a whole, or each individual component can be accessed separately. |
|
|
|
|
|
|
|
|
The one-dimensional array gives a name to a sequential group of components. Each component can be accessed by its relative position within the group, and each component is a variable of the component type. To access a particular component, we give the name of the array and an index that specifies which component of the group we want. The index can be an expression of any integral type, as long as it evaluates to an integer from 0 through the array size minus one. Array components can be accessed in random order directly, or they can be accessed sequentially by stepping through the index values one at a time. |
|
|
|
|
|