Both your functions are legal and fine, apart from that you're later leaking the free store objects from both functions.
The first function returns a reference to the value on the free store, which is copied into your local variable in main. The second function returns a pointer to the instance on the free store, which is stored into a pointer variable in main.
Your problem is in that you do not print the second string, you print the address of it, thanks to that there's an operator<< that prints the address a pointer contains as a number.
If you intend to access the contents of the second variable, you should dereference it when using it.