Link to home
Start Free TrialLog in
Avatar of VBStudent
VBStudent

asked on

3-D Arrays in C++

I'm trying to recall how to build a 3-D array in C++.  I know that 2-D arrays can be declared as int myArray[#rows][#cols] but if I remember correctly, doesn't a 3-D have to be constructed with new int** filling each single dimension array then adding the next dimension or layer on top of it?  Along those same lines, after the array is constructed, what is the order or dimension that the brackets refer to?  ie.  myArray[#deep][#rows][#cols] ?? isn't that the most widely accepted abstracted view?  Elaborating a little bit more, to calculate the address of an element in integer myArray[2][3][4] in myArray with the following dimensions myArray[5][6][7]  the calculation would be something like this address = base + ((2*6+4) * 7 + 3) * (sizeof int)
SOLUTION
Avatar of HendrikTYR
HendrikTYR

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of VBStudent
VBStudent

ASKER

Thanks for the help and the prompt response.  I actually needed both solutions.  Thanks to both of you.