Page 1 of 1
header files in C++
Posted: Wed Jun 02, 2010 3:09 pm
by SukhdeepMankoo
I have seen header files in c++ are without *.h extension.while extension is preserved in c. why need to declare header files without any *.h extension? what will its benefit.
Thanks
Re: header files in C++
Posted: Wed Jun 02, 2010 5:05 pm
by Neo
Though .hpp is used in some of the modern C++ environments, .h is inherited and still used under C++. So practically you can use either .h or .hpp for header files under C++. But I don't think the extension of the header file matters at all as those are not getting compiled (Just added to the source file where #include directive appears).
However, you will have to use .CPP for C++ source files since C/C++ compilers mostly detect the compilation method based on the extension.
Re: header files in C++
Posted: Wed Jun 02, 2010 5:25 pm
by SukhdeepMankoo
Thanks.
But i have also seen header file, where it does not have any extension.what abt that? why header files do not carry any extension.
Re: header files in C++
Posted: Wed Jun 02, 2010 6:00 pm
by Neo
That's alright. As said before, when you put the #include directive, the header file will be placed on your source file, that's all. So it can have any extension or no extension at all.
Re: header files in C++
Posted: Fri Jun 04, 2010 12:20 pm
by SukhdeepMankoo
Thanks Neo.