On 7/14/24 5:21 AM, wij wrote:
Why g++ reports "error: invalid types ‘unsigned int[int]’ for array subscript"?
--------------------------
void t() {
int z[3][3][3] = {
{{1,2,3}, {4,5,6}, {7,8,9}},
{{11,12,13}, {14,15,16}, {17,18,19}},
{{21,22,23}, {24,25,16}, {27,28,29}},
};
cout << z[1][2][0]; // OK
for(unsigned int x=0; x<3; ++x) {
for(unsigned int y=0; y<3; ++y) {
for(unsigned int z=0; z<3; ++z) {
This z hides the array z, so below the z refers to the single int, not
the array
// cout << z[x][y][z];
cout << z[1][2][0]; // g++ error: invalid types ‘unsigned int[int]’ for array subscript
}
}
}
}
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)