using namespace std;
typedef vector<string> StringArray;

void main()
StringArray arr;

string & sName = arr[3];

cout << sName.c_str();

What will happen when the variable sName is accessed?

  1. Not an issue – vector by default allocates an array of size 8 by default
  2. Cannot access – throws an out of bounds exception
  3. Can access but gives junk data / access violation

According to you what should happen when out of bound access is made? Think it out before you check the real rationale behind the way STL behaves.