When compiling the below function, following is the compilation error. why is yt != endIx
in the 2nd for loop illegal.
error C2678: binary '!=' : no operator found which takes a left-hand operand of type 'std::_Vector_iterator<std::_Vector_val<std::_Simple_types<int>>>' (or there is no acceptable conversion)
void printDebug(vector <int> ar)
{
for (auto it = ar.begin(); it != ar.end(); it++)
{
auto endIx = ar.end() - it;
for (auto yt = ar.begin(); yt != endIx ; yt++)
{
cout << *it << " : " << endIx ;
}
cout << endl;
}
}
Just to avoid confusion i have renamed the auto end iterator to endIx;
Aucun commentaire:
Enregistrer un commentaire