int *intArr[3][3] {{0}, {0}, {0}};
for (int** i : intArr){
for (int j=0; j < 3; ++j){
std::cout << i[j];
}
}
However, when I try do the following:
int *intArr[3][3] {{0}, {0}, {0}};
for (int** arrayOuter : intArr){
for (int* element : arrayOuter){
std::cout << *element;
}
}
The compiler spits out a very lengthy error, the beginning of which reads: loops.cpp:32:23: error: no matching function for call to 'begin(int**&)'
for (int* element : arrayOuter)
Now, my understanding is that intArr is a pointer to the the first element of the array, which itself is a pointer-to-int array. This means that for each iteration of the outer for loop the variable arrayOuter is initialized to a pointer-to-pointer-to-int, or simply stated: arrayOuter is an array-of-ints. This implies that each element of arrayOuter is a pointer-to-int. However, the compiler does not agree with my logic.
Thank you in advance for your feedback.

New Topic/Question
Reply



MultiQuote





|