3D Array with multiple values in each cell- please help

How can I use objects to create an an array with the dimensions 100x100x100 where each cell contains 35 different values?
In other words you need 100x100x100x35 values.

If all 35 values are of same type T, then you could allocate a 4D array. You would use dynamic allocation, for don't want that something that big in stack.

If the 35 values have different types, then define a struct that has those 35 members and allocate 100x100x100 structs.


While it is possible to create multidimensional arrays, do consider using just 1D array, because you can convert (x,y,z) 3D index into 1D index.


Prefer std::vector as the dynamically allocated array.
thank you very much!
You can not define the allocate number 100 multiple 3 times in given proper value. For get 35 member values you can use it proper way like 1 , 2, 3 d array. Here you have define is not a proper way to define.
such as:-

If the 35 values have different types, then define a struct that has those 35 members and allocate 100x100x100 structs.


While it is possible to create multidimensional arrays, do consider using just 1D array, because you can convert (x,y,z) 3D index into 1D index.

For more visit:- http://www.traininginlucknow.in/best-c-language-training-in-Lucknow.html


Topic archived. No new replies allowed.