title: What is the proper way to return an object from a C++ function?
body: <p>I am confused between :</p>
  
  <ul>
  <li>returning an <strong>object</strong> (but then the object is copied from the local variable in the function, which consumes memory)</li>
  <li>returning a <strong>pointer</strong> (but then you have to remember to delete it, in the calling code, which is weird)</li>
  <li>returning a <strong>reference</strong> (but this is not possible because this would be a reference to a local variable of the function, which would be deleted as soon as the function ends)</li>
  </ul>
  
  <p>I am looking for the proper way to return an object from a C++ function, in basic C++ (no library handling pointers and freeing memory automatically). I want to know how this is supposed to be done.</p>
  
  <p>Thank you</p>