• Advertisement

Archived

This topic is now archived and is closed to further replies.

Multi-level Dynamic Arrays

This topic is 5495 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

Whew! I got so caught up in the Programmers = God debate that I forgot what I came here to ask 2 hours ago: type* matrixPtr = new type[1][2]; gives an error. How do I create these monstrosities?

Share this post


Link to post
Share on other sites
Advertisement
Thanks CWizard.

A summary of that thread:

    
// Pointer-to-array requires pointer-to-pointer type!


some_type **whatever = new some_type*[dim1_size];

for(i = 0; i < dim1_size; i++)
whatever[i] = new some_type[dim2_size];

// Just be careful afterwards when deleting this ...

// I can't swear to the accuracy, but here's what I would do:


for(i = 0; i < dim1_size; i++)
delete[] whatever[i];

delete[] whatever;


[edited by - Orikal on February 7, 2003 1:43:45 AM]

Share this post


Link to post
Share on other sites

  • Advertisement