title: Overload operator =
body: <p>I want to overload operator =. </p>
  
  <p>That's my code </p>
  
  <pre><code>#define w 10
  #define l 10
  
  class grid
  {
  private:
      char battle_grid[w][l];
      [...]
  public:
      grid();
  [...]
      void show_grid();
      grid&amp; operator=(const grid&amp; ex)
      {
          battle_grid[w][l] = ex.battle_grid[w][l];
          return *this;
      }
  }
  
  grid::grid()
  {
  int i,j;
      for(i=0;i&lt;w;i++) {
          for(j=0;j&lt;l;j++) {
              battle_grid[i][j] = '.';
          }
      }
  }
  </code></pre>
  
  <p>and when i try something like this in function main:</p>
  
  <pre><code>int main()
  {
      [...]
      grid p1, p2;
      [...]
      p2 = p1;
      p2.show_grid();
      return 0;
  }
  </code></pre>
  
  <p>it doesn't work and i don't know why. Grid p2 is empty. </p>