lundi 21 février 2022

Getting an error while using begin and end iterators

vector <vector<int> > v8;
int N;
cin >> N;
for (int i = 0; i < N; i++)
{
    int n;
    cin >> n;
    vector <int> temp;
    for (int i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        temp.push_back(x);
    }
    v8.push_back(temp);
    
}

vector <int> ::iterator it;
for (it = v8.begin(); it < v8.end(); it++)
{
    cout << (*it) << " ";
}

I'm getting this error:

no operator "=" matches these operandsC/C++(349)
intro.cpp(161, 13): operand types are: __gnu_cxx::__normal_iterator<int *, std::vector<int, std::allocator<int>>> = __gnu_cxx::__normal_iterator<std::vector<int, std::allocator<int>> *, std::vector<std::vector<int, std::allocator<int>>, std::allocator<std::vector<int, std::allocator<int>>>>>

How should I solve this??

Aucun commentaire:

Enregistrer un commentaire