Fylhan's links lounge, le 08/09/2014 à 10:51
* Never #include unnecessary header files.
* Never #include a header when a forward declaration will suffice.
** Prefer to #include <iosfwd> when a forward declaration of a stream will suffice.
** A dependency is only mention as a return type: doesn't require a definition, but it is better to add it for the caller convenience (he will be able to use auto val = x.h();)
** A dependency is only mention as a parameter type, or bother a parameter type and a return type: doesn't require a definition
Ces deux derniers point ne sont pas vrais en Qt si c'est dans la définition d'un signal ou d'un slot. Qmake génère un moc_*.cpp à partir du *.h, et il a besoin des définitions des paramètres.
(
Permalink)