educative.io

Educative

How can the Graph class work in C++

I don’t understand the line

adjacencyList[u].push_back(v);

adjacencyList is a simple list, and according to its declaration it is just a list :
list *adjacencyList; //store adjacency list

Also, lists in C++ don’t have the [] operator, so I don’t understand how this code works.
I believe it misses a line like
adjacencyList = array<list, vertices>;

The current code compiles but fails to produce the designed output. I found a very similar code here, and they do initialize the array in the constructor.