+ 3
What does it mean i didn't understand pls help? for (auto x : adj[v]) { cout << "-> " << x; printf("\n");
Pls provude me a clear idea that what is this auto used here is it true or not?.
4 Answers
+ 2
'auto' is a type specifier that lets the compiler deduce the actual type of the variable:
https://en.cppreference.com/w/cpp/language/auto
https://www.sololearn.com/learn/442/?ref=app
In this case, the for-loop iterates over all elements 'x' of adj[ v ], which is of type std::list, I suppose, and prints each of them to the screen. Using 'auto' eases this process, as we don't really need to know what type of elements the list contains (could be anything, since the list is templated), because the code is valid as long as said type has an overloaded output operator <<.
+ 2
The output will break
+ 1
Is about to break line of out put
- 1
Dno