What is the difference between
.hpp in C ++ ? Which is better to use?
Strictly speaking, there is no difference between them at all. The only difference is how the IDE interprets them.
.h , if you follow some logic, is the header for C (
.c ), while
.hpp is the header for C ++ (
.cxx etc.). But all this is conditional and depends on the preferences and IDEs used. For example, in Visual Studio we have
.cpp files by default.
In my opinion, the only place where different naming can be beneficial is in a project where C and C ++ code is combined. Then it's worth having
.c for C code and
.cpp for C ++ when. I don't see any other uses besides personal preferences.