[quote author="Volker" date="1313088183"]
[quote author="loladiro" date="1313076273"]A pointer is not destroyed at the end of a function. A variable that is created on the stack is.
[/quote]
Sorry for nitpicking here :-)
The pointer actually is destroyed (it is treated like an ordinary variable and it is created on the stack too), it's the object it points to that survives (and that is created on the heap). If you do not save the objects address somewhere else (explicitly or implicitly using e.g. Qt's parent-child-relationship of QObject based classes), that object is lost and can never be accessed again, thus leading to a memory leak.[/quote]
Volker, you're right of course, should have mentioned that. Also, I don't mind nitpicking at all. It is quite useful to get the details right.