title: Deleting a reference to a locally-created pointer
body: <p>Consider I have the function:</p>
  
  <pre><code>int &amp;create_ptr(){
      int *x = new int;
      *x =5;
      return *x;
  }
  int main(){
      int y = create_ptr();
  }
  </code></pre>
  
  <p>Will this cause a memory leak or is there somehow to delete it?
  Sorry if it's a basic question, this has just been bugging me and I couldn't really find the answer.</p>
  
  <p>Thank you everyone, makes sense now!</p>