title: how to create a contiguous 2d array in c++?
body: <p>I want to create a function that returns a contiguous 2D array in C++.</p>
  
  <p>It is not a problem to create the array using the command:</p>
  
  <pre><code> int (*v)[cols] = new (int[rows][cols]);
  </code></pre>
  
  <p>However, I am not sure how to return this array as a general type for a function. The function is:</p>
  
  <pre><code>  NOT_SURE_WHAT_TYPE create_array(int rows, int cols)
    {
          int (*v)[cols] = new (int[rows][cols]);
          return v;
    }
  </code></pre>
  
  <p>I tried double*[] and double** and both don't work. I wouldn't want to use double*, since I want to access this array from outside as a 2D array.</p>
  
  <p>Related question: <a href="https://stackoverflow.com/questions/936687/how-do-i-declare-a-2d-array-in-c-using-new">How do I declare a 2d array in C++ using new?</a></p>