+ 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?.

17th Aug 2019, 10:54 AM
Piyush Srivastava
Piyush Srivastava - avatar
4 Respostas
+ 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 <<.
17th Aug 2019, 11:15 AM
Shadow
Shadow - avatar
+ 2
The output will break
21st Sep 2019, 11:15 AM
Newland Lotsu
Newland Lotsu - avatar
+ 1
Is about to break line of out put
22nd Aug 2019, 5:18 PM
TANIYA Sharma
TANIYA Sharma - avatar
- 1
Dno
31st Aug 2019, 8:24 AM
Omar Haefnawe