StringVec func(StringVec & str1, Stringvec & str2)
{
std::vector<string>::iterator s2 = str2->vec.begin();
for (std::vector<string>::iterator s = str1->vec.begin(); s != str1->vec.end(); ++s)
{
if(s2 == NULL)
{
cout << "str2 is smaller than str1" << endl;
}
++s2;
}
}
When a iterator goes out of bound, because the vector is smaller, won't that possibly create a situation where the pointer points to some rubbish instead of NULL? So how do I make the code above work in all situation?