I'm somewhat new to programming in general and I've run into an issue with declaring 3D and 4D arrays. I have several declarations like this at the start of my main function, but I've narrowed the problem down to these 4:
string reg_perm_mark_name[64][64][64];
short reg_perm_mark_node_idex[64][64][64];
short reg_perm_mark_rot[64][64][64][4];
short reg_perm_mark_trans[64][64][64][3];
When I run my program with these, I get "System.StackOverflowException" in my executable. I would much prefer a way to allocate them dynamically, The way I have it now was meant to be temporary anyway and I'm not sure how to declare array pointers properly.
The 4 elements I'm using in the 4D array reg_perm_mark_trans, for example, are [node index][region index][marker index][xyz coordinates]. Also there's a total of 35 multidimensional arrays being declared at once. (most of them are 1D and 2D) I'm not sure if that helps.
Can someone show me how to make these 4d arrays work or maybe how to make them dynamically allocating with pointers or vectors? Be descriptive please, I'm still learning.
vectoretc. (which usesnewinside, this isn´t limited.). There are enough examples how to usestd::vectorin the Internet.std::arrayis a great substitute for naked multidimensional arrays. Same goes forstd::vectorwhen you're working with dynamically sized multidimensional arrays.std::arrayat least is a decent substitute for multidimensional arrays. Not so much withstd::vectorthough - you have to choose between manually flattening the index, or using a "jagged array" instead of a true multidimensional array.std::vector. You'll have even more overhead trying to manage a dynamically sized multidimensional array yourself than you will usingstd::vector. The really nice thing is you can mix and match them with the greatest of ease so you get the best of both worlds without all the overhead and headache you get by dismissing the usefulness of standard containers.