| < Day Day Up > |
|
An array is a ______________ allocation of memory to _____________ objects.
contiguous / homogeneous
A static array name is what type of pointer?
const pointer
(T/F) An array name points to the first element of the array.
TRUE
How are multi-dimensional arrays stored in memory.
Row major order
Multi-dimensional arrays are arrays of ______________.
arrays
What determines the size of an allocation unit?
The data type.
How does a dynamically allocated array differ from a statically allocated array?
The elements of a dynamically allocated array are stored in heap memory.
List at least four types of objects an array can contain.
Fundamental data types
User-defined data types
Pointers to fundamental data types
Pointers to user-defined types
Pointers to members
Enumerated types
Other arrays
Describe the two methods available to access array elements.
Subscript method
Pointer arithmetic method
To what values will the array elements be initialized to in the following declaration:
int int_array[25];
The array will contain garbage values.
To what values will each array element be initialized to in the following declaration:
int int_array[25] = {1,2,3};
The first three elements will be 1, 2, 3, and the rest will be initialized to 0.
What is the difference between the new operator and the new[] operator?
The new operator allocates memory for new objects; the new[] operator allocates memory for arrays
Why is it important to release dynamically allocated array memory with the delete[] operator?
Because the delete[] operator is the array equivalent to the delete operator. Any memory allocated with new[] should be released with delete[].
List and discuss the steps required to create a single-dimensional dynamic array.
Declare a pointer to the type of array elements
Create the array with the new[] operator
Create each element object as required with the new operator
---- when done with array
Delete each element object with the delete operator
Delete the array pointer with the delete[] operator
Discuss the two methods for creating multi-dimensional dynamic arrays. Which method would you prefer to use and why?
The first method is to statically allocate the smallest set of elements and dynamically allocate the largest
The second method is to dynamically allocate all dimensions of the multi-dimensional array. A multi-dimensional array is just an array of arrays.
| < Day Day Up > |
|