title: Could this cause a memory leak, returning array from function?
body: <p>I have the following code which works fine except I'm not sure if I need to delete the <code>returned_array</code> pointer in the <code>int main()</code> or if its automatically deleted. I will guess its not automatically deleted and assume I should use <code>delete returned_array;</code> after the <code>cout</code> is finished. Any suggestions?</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  double* pass_return_array(double passed[])
  {
          double* returned_array = new double[3];
  
          for(int index = 0; index &lt; 3; index++)
              returned_array[index] = passed[index];
  
          return returned_array;
  }
  int main()
  {
          double passed[3];
          double* returned_array;
  
          for(int index = 0; index &lt; 3; index++)
              passed[index] = index + 100;
  
          returned_array = pass_return_array(passed);
  
          for(int index = 0; index &lt; 3; index++)
              std::cout&lt;&lt;returned_array[index]&lt;&lt;std::endl;
  
          return 0;
  }
  </code></pre>