I am trying to initialize two iterators two my 2D vector, one for the rows and one for the columns. I have done it this way:
vector<vector<int> > v;
vector<vector<int> >::iterator r;
vector<int>::iterator c;
r = v.begin();
c = r->begin();
and i get the following pop-up window, when i run the code: Debug Assertion Failed! Expression: can't dereference value initialized vector iterator.
There are som problem with this statement:
c = r->begin();
But cant see why?
Thanks
v
is empty, sor
doesn't point to a validvector<int>
instance (there is no instance to point to). You are essentially dereferencingv.end()
, whereupon your program exhibits undefined behavior.