Answer the question
In order to leave comments, you need to log in
What does such an expression mean?
I came across this entry:
int main()
{
std::list<int> x = {1, 2, 2, 3, 3, 2, 1, 1, 2};
std::cout << "contents before:";
for (auto val : x)
std::cout << ' ' << val;
std::cout << '\n';
}
for (auto val : x)
Answer the question
In order to leave comments, you need to log in
Discover C++11. This is a new language standard that has improved syntax.
for (auto val : x) is a loop through the collection x, each element of the collection will be copied to the x variable.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question