Qt Why Use .h And .cpp Rather Than .hpp? - Qt Forum

Skip to content Collapse Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt why use .h and .cpp rather than .hpp?
Forum Updated to NodeBB v4.3 + New Features Qt why use .h and .cpp rather than .hpp? Scheduled Pinned Locked Moved Solved General and Desktop 4 Posts 3 Posters 2.8k Views Oldest to Newest
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply This topic has been deleted. Only users with topic management privileges can see it.
  • LimerL Offline LimerL Offline Limer wrote on last edited by #1

    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?

    aha_1980A 1 Reply Last reply 0
  • LimerL Limer

    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?

    aha_1980A Offline aha_1980A Offline aha_1980 Lifetime Qt Champion wrote on last edited by #2

    @Limer

    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.

    Qt has to stay free or it will die.

    1 Reply Last reply 6
  • VRoninV Offline VRoninV Offline VRonin wrote on last edited by #3

    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

    "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours" ~Napoleon Bonaparte

    On a crusade to banish setIndexWidget() from the holy land of Qt

    1 Reply Last reply 6
  • LimerL Offline LimerL Offline Limer wrote on last edited by #4

    Thanks a lot for your warm response. I see..

    1 Reply Last reply 0
  • First post Last post Go to my next post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
  • Search Search

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.

Từ khóa » .h .cpp .hpp