title: Passing and Returning a 2D array of unknown size in C++
body: <p>I want to pass and return a 2D array of unknown size but I donot know how to do it. I know how to only return array of unknown size only (array of pointers). I know how to pass array of unknown size(templates) , but passing and returning a 2D array of unknown size at the same time is not working for me. I have the following code</p>
  <pre><code>template&lt;typename Value_t, size_t FirstDim, size_t SecondDim&gt; 
  int** FooTakes2D_ArrayRef_to_Print(Value_t (&amp;array2d)[FirstDim][SecondDim]) 
  { 
      for(size_t i=0; i&lt;FirstDim; ++i) 
      { 
          for(size_t j=0; j&lt;SecondDim; ++j) 
          { 
              std::cout&lt;&lt;array2d[i][j]&lt;&lt;' '; 
          } 
          std::cout&lt;&lt;&quot;\n&quot;; 
      } 
   
   return array2d; 
  } 
   
  int main() 
  
  { 
     
      double arr_d[][3]= { {1,2,3},  {4,5,6} }; 
      int** arr=FooTakes2D_ArrayRef_to_Print(arr_d);
  
   
  return 0; 
  
  }
  </code></pre>