title: Deleting pointer before returning value from function
body: <p>If I have this:</p>
  
  <pre><code>double foo()
  {
  double* ptr = new double(0);
  
  return *ptr;
  }
  </code></pre>
  
  <p>If ptr is not deleted before returning, this will cause a memory leak? Therefore, what is the correct way to delete ptr before returning from the function?</p>