Iterating through multidimensional arrays
With a one dimensional array, you can iterate through it like so:
for (int i : arr) {
    // code
}
But why, when you are using a multidimensional array, do you have to use
references?:
for (int &row : arr) {
    for (int &col : row) {
        // code
    }
}
 
No comments:
Post a Comment