Skip to main content
GameDev.net gamedev.net
🔒 Locked

Array declarations multidimensional..

Started by JizzRoy Oct 13, 2000 at 12:37 PM 2 replies 300+ views
Original Post
JizzRoy
JizzRoy
How do I dynamically declare a multidimensional array using NEW? where BOTH parameters are dynamic. Thanks
SeanHowe
SeanHowe
I''m not sure if it''s possible, but why do you even need a multidimensional array? Everything you can do with one is easily emulated with a one dimensional array of the size [width*height]
Myopic Rhino
Myopic Rhino
You have two options:

  1. Create a one dimensional array, and access it using array[y * maxX + x] (or a similar form for more than 2 dimensions
  2. Create an array of pointers, and then loop through it dynamically creating creating an array to assign to each pointer. Repeat if there are more than 2 dimensions.


There is no way to directly create a multidimensional array with a single call to new.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.