TwentyFourSeven
asked on
Vectors of Vectors
Is my misunderstanding of C++ vectors flawed ?
vector<vector<int> > myVec(10,vector<int>(8));
cout << myVec[9][8] << endl;
cout << myVec[10][8] << endl;
0
Bus error
What's up with element 10 ?
vector<vector<int> > myVec(10,vector<int>(8));
cout << myVec[9][8] << endl;
cout << myVec[10][8] << endl;
0
Bus error
What's up with element 10 ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
vector<vector<int> > myVec(10,vector<int>(8));
cout << myVec[9][8] << endl;
0
Program exited normally.
(gdb)
cout << myVec[9][8] << endl;
0
Program exited normally.
(gdb)
>> If that is the case, why is it allowing me to access elemet 8 of the inner vector ?
It's not because it might work in some cases that it's not wrong.
It's not because it might work in some cases that it's not wrong.
ASKER