According to Stroustrup in "The C++ Programming Language", "The standard library vector does not provide range checking by default." I.e.,
1 2 3 4 5 6 7 8 9 10
struct Entry {
string name i;
int number;
} ;
vector<Entry> book(1000) i; // vector of 1000 elements
int i = phone_book[1001].number; // 1001 is out of range
does not give an error (according to the book, I've not tested this.
Why not? I understand how to handle this with at() but why is there the flexibility to allow a vector to use out-of-range indexes? What is the advantage?