delete pointer to 2d array c ++
- by user1848054
i have this pointer to 2d array of Robot class
Robot ***rob;
and this is here the code for the constructor !! and the program 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 to delete this pointer to 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;
}
}
}