How can I create a 3D-array only with Qt-Objects? The array should be a 3D-integer-array. I have tried to create a standard 3D-array on the heap. To allocate the memory on the heap works fine. I got an error if i want to deallocate the memory.
const int scalefaktor = 16;
int*** anzPixel3d = new int**[256/scalefaktor];
for (int i = 0; i <= 256/scalefaktor ; i++)
{
anzPixel3d[i] = new int*[256/scalefaktor];
for (int k = 0; k <= 256/scalefaktor ; k++)
{
anzPixel3d[i][k] = new int[256/scalefaktor];
}
}
for (int j = 0; j <= 256/scalefaktor ; j++)
{
for (int m = 0; m <= 256/scalefaktor ; m++)
{
delete [] anzPixel3d[j][m];
}
delete [] anzPixel3d[j];
}
delete [] anzPixel3d;
For this project I use Qt4.8 and the Qt-Creator 2.7.0. I use the MSVC2010 compiler.
The error-message is: HEAP CORRUPTION DETECTED: after Normal block (#31715) at 0x006E3C0. CRT detected that the application wrote to memory after end of heap buffer.