Getting vector iterator not deferencable for code below, but I don’t see why. I am simply iterating through the 2d array and instantiating all values to 0. Where am I iterating to an invalid location?
vector<vector<bool>> isduplicate(100);
for(int i=0;i<isduplicate.size();i++){
for(int s=0;s<isduplicate.size();s++)
isduplicate[i][s]=false;
}
You are iterating over
isduplicatetwice. You should iterate overisduplicate[i]in the inner loop:However,
isduplicate[i]is empty for alli, therefore you won’t iterate over anything in the inner loop.If what you want is to have 100 vectors of 100
bools containing thefalsevalue, then:Should do it.