I am creating a three dimensional array like this:
GLfloat ***tgrid;
//other code in between here
tgrid = new GLfloat**[nx];
for(int i = 0; i < nx; i++)
{
tgrid[i] = new GLfloat*[ny];
for(int j = 0; j < ny; j++)
{
tgrid[i][j] = new GLfloat[nz];
}
}
Does this mean i should deallocate the memory like this:
for(int i = 0; i < nx; i++)
{
for(int j = 0; j < ny; j++)
{
delete [] tgrid[i][j];
}
delete [] tgrid[i];
}
delete [] tgrid;
?
I know that they are supposed to go in "reverse" order but I'm not sure I'm doing it right ... Does this seem correct?