Remember to include the header file
type of each element
name of array
subscript (integer number or constant expression
representing the number of elements.)
The subscript is the number of elements in the array,
surrounded by parentheses. For
apvector <int> num(10);
declares an array named num
that contains 10
integers. When the compiler encounters this declaration, it immediately
sets aside enough memory to hold all 10 elements.
A program can access each of the
array elements (the individual cells) by referring to the name of the array
followed by the subscript which denotes the cell. For example, the third
cell is denoted num.
of array elements begin with zero.
apvector class has a
subscript checking code that displays an error message when the program uses a
subscript that is out of the range of the array - a really nice feature!!