• Advertisement
Sign in to follow this  

allocating multidimensional arrays?

This topic is 3811 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i know how to create an multidimensional array, but not how to allocate it on the heap.
[source langg = "cpp"]
const int maxpoints = 250;
const int maxpixels = 5;

point* mousepoints = new point[maxpoints][maxpixels];

obviusly dosent work.

Share this post


Link to post
Share on other sites
Advertisement
You cannot allocate multidimensional arrays on the heap (because the first dimension should be fixed). You can use vectors-of-vectors or boost::multi_array in a much easier fashion.

Also, technically, new allocates memory on the free store (the heap is where malloc gets its memory from).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement