vector<int> solution;
vector<int>::iterator col;
vector<int>::iterator row;
vector<int>::iterator sum;
...
for (row = vec.begin(); row != vec.end(); ++row)
{
sum = solution.begin();
for (col = row->begin(); col != row->end(); ++col)
{
if(sum == (solution.end())) //value for solution.end() doesn't change, while vector keeps growing
{
solution.push_back(*col);
}
*sum = (*sum + *col); //leads to segfault
++sum;
}
}
I'd like to have a condition that allows me to check for growing vectors, but how the iterator is implemented in c++ as it doesn't allow me to do that. What should I use then?