delete pointer to 2d array c ++
Posted
by
user1848054
on Stack Overflow
See other posts from Stack Overflow
or by user1848054
Published on 2012-11-23T16:40:02Z
Indexed on
2012/11/23
17:05 UTC
Read the original article
Hit count: 519
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;
}
}
}
© Stack Overflow or respective owner