apvector <double> grade(100);
The elements of this array can be referred to
in a program as
grade . . . grade.
the program is compiled, the compiler does not save the addresses of all of the
elements, but only saves the address of the first element,
When the program needs to access any element, such as grade,
it calculates the address by adding units to the address of grade.
The number of bytes in each unit is equal to the number of bytes required to
store an element of the array. In this example, the number of bytes in
each unit is 8 bytes (needed to store a double).
The address of grade
be obtained by using the
& ("address of") operator.
In C++, the name of the array,
grade, without a
subscript, is the same as &grade.
The name of the
array is the address of the first element of the array.
cout<< grade; //will print the address of first element of
// the array, assuming no other variable is
// defined as 'grade'.