previous | start | next

## Vector Subscripts

- Trying to access a slot that does not exist in the vector is an error.

  >     vector<double> staff(10);
  >     cout << staff[10]; /* legal subscripts are 0 until 9 */

- The C++ standard implementation of `vector` generates no error message.
- If you make an index error, you silently read or overwrite another memory location.
- When a vector is defined without a size parameter, it is empty and can hold no elements.

  >     vector<double> salaries; /* no size given */
  >     salaries[0] = 35000;

previous | start | next