Multidimensional Dynamic Memory Arrays
| Mayflower (25) | |||
Any way to make a multi dimensional dynamic array?
??? | |||
| alex79roma (36) | |||||
| you can use the new instruction only to allocate object of a class type, you defined byte as a unsigned char, this is a primitive type, it's not a class so it doesn't work. you may use the C calloc(...) function but it's not very simple at first sight
I think you may start with studying the malloc(), realloc(), calloc(), free() functions of the C language on this site. You can find these functions in: Reference->C Library->cstdlib in the paragraph "Dynamic memory management" I just give you a simple example here:
I hope it can help you! Good luck! | |||||
| Mayflower (25) | |||
| Thanks! | |||
| alex79roma (36) | |||
Mayflower i think you needed this.
I'm very sorry but i discovered it just now. I hope this helps you. | |||
| mikosz (2) | |||
| Exactly, that's the proper way. And remember, that you can't just delete[] a multidimensional array - you need to delete it row by row, just as you create it. Have fun. M | |||
This topic is archived - New replies not allowed.
