#include <iostream>
#include <vector>
#include <list>
using namespace std;
int main()
{
vector<list<string> > testList;
testList[2].push_back("ADA");
return 0;
}
It got a thread, when program running.
signal: “EXC_BAD_ACCESS”
I guesse it’s because of illegal memory access,
but I don’t know why and how to fix it.
thanks so much
testListhas length 0 after initialization, therefore you cannot accesstestList[2].You can pass an initial size to the c’tor of std::vector, so the following should work