Most of memory leaks appear when a pointer of an object returned and programmer forgot to delete it.
for example:
class my_class
{
...
};
my_class
Don't return raw pointers from functions; stick them in a smart pointer class such as unique_ptr or shared_ptr. Then you don't have to worry about deleting the allocated object.
Also, in your second example, who is deleting the object allocated by func1()? Just because you return a reference instead of pointer doesn't mean freeing of allocated memory will happen magically.