title: C++ 2D dynamic array crash
body: <p>Hi I'm having some problem with 2D dynamic array.</p>
  
  <pre><code>int main()
  {
     double **M;
     int M_dimension;
     int i;
  
     M_dimension = 10;
  
     M = new double *[M_dimension];
     for (i=0;i&lt;M_dimension;i++)
     {
        M[i] = new double[M_dimension];
     }
  
     M[0][0] = 1.0;
  
  ...
  }
  </code></pre>
  
  <p>Program works but I'd like to initialize 2D array using such a function:</p>
  
  <pre><code>void initialize2D(double **M,int M_dimension)
  {
     int i;
     M = new double *[M_dimension];
     for (i=0;i&lt;M_dimension;i++)
     {
        M[i] = new double[M_dimension];
     }
  }
  </code></pre>
  
  <p>Finally the program looks like this:</p>
  
  <pre><code>int main()
  {
     double **M;
     int M_dimension;
     int i;
  
     M_dimension = 10;
  
     initialize2D(M,M_dimension);        
  
     M[0][0] = 1.0; //crash
  
  ...
  }
  </code></pre>
  
  <p>Unfortunately it crashes at <code>M[0][0] = 1.0;</code></p>
  
  <p>Thanks for any help or suggestions.</p>