Header Files, Source Files, & Extension Names–C++ Notes (C Plus Plus Notes)
What’s the difference between Header files & Source files?
Basically, header files are #included and not compiled, whereas source files are compiled and not #included.
So do not compile ‘.h‘ files, and do not #include ‘.cpp‘ Source files.
Also, do not #include the same .h file twice. This will lead to an error.
Extensions
- All files are fundamentally the same in that they’re all text file, however different kinds of files should have different extensions:
- Header files should use a .h extension (.h/.hpp/.hxx). Which particular one of these you use doesn’t matter.
- C source files should use .c (.c only). (But that’s for ‘C’ language.)