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?
- Not an issue – vector by default allocates an array of size 8 by default
- Cannot access – throws an out of bounds exception
- 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.