samedi 20 février 2021

no matching function for call to 'std::vector

I made a vector of vectors and i wanted to take values from the user.I simply don't know what is the problem with it

why can't i use push_back() here and if you have any other method than this please tell.

vector<vector<int>>  v;
for(int i=0;i<n;i++)
{
   v.push_back(i+1);
   for(int j=0;j<n;j++)
    {
        v[i].push_back(j+1);
    }
}

doing this gives me error

error: no matching function for call to 'std::vector<std::vector<int> >::push_back(int)'
v.push_back(i+1);

Aucun commentaire:

Enregistrer un commentaire