Loading...
Loading...
Loading Curriculum...
Loading Subject...
Loading Topic...
Loading Lesson...
Loading Lab...
C++ allows arrays with any number of dimensions. A 3D array can be thought of as a volume or a collection of grids.
int cube[3][3][3]; // 27 total elementsThink of it as 3 separate 2D grids (slices), each 3x3 in size.
int arr[2][2][2] = {
{ {1, 2}, {3, 4} }, // Layer 0
{ {5, 6}, {7, 8} } // Layer 1
};N-dimensional arrays consume memory exponentially. arr[100][100][100] is 1 million integers (≈4MB). Watch out for large dimensions in stack-allocated arrays.