please can someone can explain what is ::
for(auto i:adjList) and also please explain same kinda syntax??
Problem in writing For loop
Range-based for loop in C++ is added since C++ 11. It executes a for loop over a range. Used as a more readable equivalent to the traditional for loop operating over a range of values, such as all elements in a container.
Syntax :
for ( range_declaration : range_expression )
loop_statement
Parameters :
range_declaration :
a declaration of a named variable, whose type is the
type of the element of the sequence represented by
range_expression, or a reference to that type.
Often uses the auto specifier for automatic type
deduction.
range_expression :
any expression that represents a suitable sequence
or a braced-init-list.
loop_statement :
any statement, typically a compound statement, which
is the body of the loop.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.