Qt why use .h and .cpp rather than .hpp?
-
wrote on 24 Jan 2019, 08:46 last edited by
Today I came across this post https://stackoverflow.com/questions/152555/h-or-hpp-for-your-class-definitions ,
Qt is a C++ framework, and I saw all of them are*.h
and*.cpp
in source code.
So, is there any other reasons not to use*.hpp
? -
Today I came across this post https://stackoverflow.com/questions/152555/h-or-hpp-for-your-class-definitions ,
Qt is a C++ framework, and I saw all of them are*.h
and*.cpp
in source code.
So, is there any other reasons not to use*.hpp
?I think this question can be answered like most similar questions: Historic reasons.
Also note that all the official includes, like
#include <QString>
, have no extension at all. -
wrote on 24 Jan 2019, 09:25 last edited by
Header files are not compiled so it doesn't really matter, it's the content of the .cpp file that includes them to determine if they are considered C or C++.
It's pure flavour.
I normally use .hpp if the header contains definitions (like is the case with templates) and .h if it just contains declarations. The idea is to have some kind of a warning that if you include .hpp in multiple .cpp you are potentially compiling the same code twice. Once again it's just an opinion, you are free to call them as you prefer -
wrote on 24 Jan 2019, 09:53 last edited by
Thanks a lot for your warm response. I see..
1/4