Original Post
Hi!
Could someone give me a example code for c++ which allocates two-dimensional array. The array would contain classes. Here is code which I made but it didn''t work:
pointer to the array:
// CCluster is a class
CCluster ***m_pCluster;
Memory allocation:
{
m_pCluster = (CCluster ***) new CCluster();
// Allocate memory for the X elements
for(int x = 0; x < maxX; x++)
{
m_pCluster[x] = (CCluster **) new CCluster();
// Allocate memory for the Y elements
for(int y = 0; y < maxY; y++)
{
m_pCluster[x][y] = (CCluster *) new CCluster();
}
}
}
It works for example 25*25 array but if it gets bigger the program terminates. I use WinNT does it matter?
Any help would be appreciated.
Floru