in the second function use return the reference to the object and the destructor kills the object, while you only create a reference AND NOT A COPY of the returned object.
In the first function you return the object and a ref gets counted.
You need to better understand
object life cycle managment.
Learn it! ;-)