I'm trying to understand this. The way I see it, there is an array of arrays.
The first for loop loops through the the arrays rows, and the second the columns.
What is the "rows". I haven't defined any constant yet it still works. I realize I can change it to anything, I'm just unsure what is happening here.
1 2 3 4 5 6 7 8 9 10 11 12 13 14
array<array<int, collumns>, row>MDA;
int main()
{
for (auto &rows: MDA)
{
for (auto &element : rows)
{
element = true;
}
}
}
Take a look at this example because yours has some naming inconsistencies which make it more difficult to reason about:
1 2 3 4 5 6 7 8 9 10
staticconstexpr std::size_t n_rows{5}, n_columns{10};
std::array<std::array<int, n_columns>, n_rows> mda;
// row is a lvalue-reference to a particular row
for (auto &row: mda) {
// elt is a lvalue-reference to a particular ELemenT of that row
for (auto &elt: row) {
elt = 42;
}
}
In your own example, rows is declared in the outer loop, and binds to each row of MDA in order.