with the given code, my compiler does give an error saying that x has no type defined.
1 2 3 4 5 6 7 8 9 10 11
void printGraph(vector<int> adj[], int V)
{
for (int v = 0; v < V; ++v)
{
cout << "\n Adjacency list of vertex "
<< v << "\n head ";
for (auto x : adj[v])
cout << "-> " << x;
printf("\n");
}
}
What exactly are you trying to do with the range-based for loop at line 7? Range-based for loops work with entire containers, not one specific element. An element has no container begin() statement associated with it.
MAJOR brain-fart going on*. I didn't notice the OP passing a 2D container into the function. (see my follow-up reply)
*at least I caught my screw-up, eventually. *ouch*