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) {
// cout << z[x][y][z];
cout << z[1][2][0]; // g++ error: invalid types ‘unsigned int[int]’ for array subscript
}
}
}
}
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) {
// cout << z[x][y][z];
cout << z[1][2][0]; // g++ error: invalid types ‘unsigned int[int]’ for array subscript
}
}
}
}
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 490 |
Nodes: | 16 (2 / 14) |
Uptime: | 57:27:14 |
Calls: | 9,674 |
Calls today: | 5 |
Files: | 13,719 |
Messages: | 6,171,162 |