0
C++ header
Why are c++ header files included without extension .h???Does all C++ support without .h extension?If not mention the header files which do not support it
2 ответов
+ 3
For custom headers (headers you created) you still need to specify as #include "your_header.h", but for standard include files you specify the name only, omitting the file extension is the standard, as I recall from a previous thread I read.
Also for headers inherited from C, a prefix of "c" is prepended to the file name e.g. stdio.h -> cstdio, stdlib.h -> cstdlib
Hth, cmiiw
+ 2
When the C preprocessor encounters an #include declaration it copies all of the target file contents into your file. It generally doesn't take into account stuff like file extensions or anything like that.
You suffix your header files ".h" so you know what they are. The C++ standard library doesn't follow this rule because stuff like "string.h" and "iostream.h" would have broken many existing projects.