Do I need to take care of memory allocation, scope and deletion of C++ strings allocated by a literal?
For example:
<
You have a different problem with s3, namely that the function func3() returns a pointer into an object that goes out of scope when the function returns. Don't.
To clarify: Your local string object within func3() will cease to exist on return of the function, so no need to delete. However, you still have a pointer to its internal buffer, which you return. You can't use that.
Very good and detailed past answer here, lest more confusion ensues: Is it more efficient to return a const reference