I'm quite new to programming as I'm still learning how to code efficiently so my question may seem a little bit strange.
As I'm learning how to code with Qt, I know that Qt has a memory management method that the parent deletes all its children when it itself was deleted, and then there's QSharedPointer
and so many other smart pointer thing (or you may mention boost::shared_ptr
).
I understand how exactly both methods work but my question is that when it comes to the design of the whole system structure in Qt, should i make most of my class a subclass of QObject
and hand over the ownership to QT to do the memory management, or simply using boost::shared_ptr
or QSharedPointer
thing to avoid potential memory leaks ?
As there's a lot of problem to take into account if we adopt both techniques because it may cause double-delete problem.
So which technique has better performance or which is better in the design?