I have a pointer to a 2d array of Robot class
Robot ***rob;
And below is my code for the constructor. The constructor works fine, but now I am trying to build a destructor to delete this pointer and it keeps on crashing the program!
My question is, how can I delete the pointer to the 2d array of robots?
RobotsWorld::RobotsWorld(int x , int y)
{
X=x;Y=y; // returns the limitation of the matrix
rob = new Robot**[x];
for(int i = 0; i < x; i++)
{
rob[i] = new Robot*[y];
for(int j = 0; j < y; j++)
{
rob[i][j] = NULL;
}
}
}