|
-
May 6th, 2003, 05:27 AM
#1
deleting 2-Dimensional Arrays
I am allocating memory for a 2 dimensional array as follows..how do I delete it?
double (*e)[3] = new double[4][3]
Regards
mgore
-
May 6th, 2003, 06:20 AM
#2
Suggestion
I think you need to write something like this
for(int i = 0; i < 4; i++)
delete [] e[i];
delete [] e;
-
May 6th, 2003, 06:40 AM
#3
I am doing this but in Visual Studio while debugging I am getting a dialog box with the following message:
User breakpoint called from code at ..
-
May 6th, 2003, 06:49 AM
#4
A 2D array is handled internally like a 1D array, except that the compiler translates your calls to [1][5] to (max_dim*1 + 5), so to speak.
delete [] e; should actually do the trick.
-
May 6th, 2003, 07:47 AM
#5
Why do you not use the standard vector template instead? It is much easier and handles the memory on its own...
For further information take a look at this FAQ...
-
May 6th, 2003, 07:53 AM
#6
would have loved to use vector of vectors .. but the APIs which I need to call take a 2-Dimensional array of doubles, the number of columns are constrained.. and number of rows will keep varying.. so I need to allocate memory from the heap...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|