mgore
May 6th, 2003, 05:27 AM
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
double (*e)[3] = new double[4][3]
Regards
mgore
|
Click to See Complete Forum and Search --> : deleting 2-Dimensional Arrays mgore May 6th, 2003, 05:27 AM 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 ARIX May 6th, 2003, 06:20 AM I think you need to write something like this for(int i = 0; i < 4; i++) delete [] e[i]; delete [] e; mgore May 6th, 2003, 06:40 AM 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 .. rsmemphis May 6th, 2003, 06:49 AM 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. Andreas Masur May 6th, 2003, 07:47 AM 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 (http://www.codeguru.com/forum/showthread.php?s=&threadid=231046)... mgore May 6th, 2003, 07:53 AM 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... codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |