title: C++ Dynamic multidimensional array problem
body: <p>I'm developing a 2d-platformer. Everything was fine until I've got some hard to solve problem. Level map is stored in dynamic multidemension array(char **map). It works fine, until I want to redefine it</p>
  
  <p>Here's the part of code:</p>
  
  <pre><code>Map&amp; Map::operator=(const Map&amp; rhs)
  {
      if(width!=0||height!=0)
      {
          for(int i=0;i&lt;width;i++)
              delete[] map[i];
          delete[] map;
      } //deleting previously created array
  
      height=rhs.height;
      width=rhs.width; //receiving other map's size
  
      map=new char* [width];
      walkmap=new unsigned char* [width];
      objmap=new char* [width];
      for(int i=0;i&lt;width;i++)
      {
          *(map+i)=new char[height];
      } //creating new array
  
      for(int h=0;h&lt;height;h++)
          for(int w=0;w&lt;width;w++)
          {
              map[w][h]=rhs.map[w][h];
          } //receiving new values
  
      //...
  }
  </code></pre>
  
  <p>Everything works fine for the first time, but when I need to redefine array for the second time my program crashes at the part, when array is receiving new values from another one. May be I miss something, but I can't find it! I was searching for this problem, but didn't find what I am doing wrong. Help me, please.</p>