mercredi 23 décembre 2015

Modern C++ with QT

Why do official examples and tutorials about the Qt library never make use of smart pointers? I only see new and delete for creating and destroying the widgets. I searched for the rationale but I could not find it, and I don't see one myself except if it's for historic reasons/backward compatibility: not everyone wants the program to terminate if a widget constructor fails, and handling it via try/catch blocks is just ugly (even if used in few places), also the fact the parent widgets may take the ownership of the children only partially explains the thing to me, as you would still have to use delete for the parents at some level.

Aucun commentaire:

Enregistrer un commentaire