I defined a list of arrays in c++ for representing a graph. But i can’t seem to access the elements of the arrays

  arraylist, arrays, c++, list

basically this is what i did, a list of int pointers to be used as a list of arrays:

#include <list>
list<int> *l;
l = new list<int>[V + 1];

I can push_back(integer) into l[x] to create the array at "x" position on the list and i get no error. But when i use l[x][some_index] to access an element of the array at position "x" in the list, this is the error i get:

error: no match for ‘operator[]’ (operand types are ‘std::__cxx11::list’ and ‘int’)

Can someone please help me with this?
Thank you

Source: Windows Questions C++

LEAVE A COMMENT