title: Deleting pointers in destructor
body: <p>I have some pointers that I allocate in the constructor of a class and then attempt to delete in its destructor:</p>
  
  <pre><code>TileMap::TileMap(int x, int y) {
  
      mapSize.x = x;
      mapSize.y = y;
  
      p_p_map = new Tile*[x];
  
      for(int i = 0; i &lt; x; i++) {
  
          p_p_map[i] = new Tile[y];
  
      }
  
      randomize();
  
  }
  
  TileMap::~TileMap() {
  
      for(int i = 0; i &lt; mapSize.x; i++) {
  
          delete p_p_map[i];
  
      }
  
      delete p_p_map;
  
  }
  
  void TileMap::randomize() {
  
      for(int i = 0; i &lt; mapSize.x; i++) {
  
          for(int j = 0; j &lt; mapSize.y; j++) {
  
              p_p_map[i][j] = *new Tile(Tile::TileSize * i, Tile::TileSize * j, TileType::randomType());
  
          }
  
      }
  
  }
  </code></pre>
  
  <p>At the end of the program the destructor is called to free the memory of the pointers I allocated, but when it reaches "delete p_p_map[i];" in the destructor, XCode informs me that the pointer was not allocated. I am new to C++, but I feel that I pretty explicitly allocated memory to the pointers in the randomize() function.</p>
  
  <p>What error am I making?</p>