Iterating through the array

suggest change

Because std::array is a standard-library container, it can be traversed with a range-based for loop just like std::vector and other containers. Class template argument deduction in the sample is C++17; earlier dialects spell the element type and the size.

#include <array>
#include <iostream>

int main() {
    std::array values{1, 2, 3};
    for (int value : values) {
        std::cout << value << '\n';
    }
}

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents