Consider the following code:
class Search
{
    List** openList;
    int tam;
    Search(int t)
    {
        tam = t;
        openList = new List*[tam];
        for (int i = 0; i < tam; i++)
        {
            openList [i] = new List();
        }
    }
    virtual ~Search();
}
How should be the correct destructor?
Now, I have this:
Search::~Search() 
{
    for(int i = 0; i < tam; i++) 
    {
        delete openList[i]
    }
    delete[] openList;
}
But, this code breaks my program when I execute this recurrently (sometimes in init and sometimes in destructor) so... it's incorrect.
Any idea?
Thanks you so much :)!
 
     
    
` and forget about explicit heap allocation.
– Igor Tandetnik Mar 20 '16 at 19:12