The following are examples of the
‘range-for’ statement:
for (auto element : vector) {}
for (auto& element : vector) {}
for (const auto element : vector) {}
for (const auto& element : vector)
{}
The first returns copies of the vector
elements in the loop, and the second returns references to the vector elements
in the loop. The third and fourth examples are const versions of the first two.
No comments:
Post a Comment