c++headernaming-conventionsfile-type

*.h or *.hpp for your C++ headers / class definitions


I've always used a *.h file for my class definitions, but after reading some boost library code, I realised they all use *.hpp. I've always had an aversion to that file extension, I think mainly because I'm not used to it.

What are the advantages and disadvantages of using *.hpp over *.h?


Solution

  • Here are a couple of reasons for having different naming of C vs C++ headers:

    Remember, C is not C++ and it can be very dangerous to mix and match unless you know what you are doing. Naming your sources appropriately helps you tell the languages apart.