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
header files in C++
-
- Lieutenant
- Posts: 92
- Joined: Tue Oct 27, 2009 7:50 pm
Re: header files in C++
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.
However, you will have to use .CPP for C++ source files since C/C++ compilers mostly detect the compilation method based on the extension.
-
- Lieutenant
- Posts: 92
- Joined: Tue Oct 27, 2009 7:50 pm
Re: header files in C++
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.
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++
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.
-
- Lieutenant
- Posts: 92
- Joined: Tue Oct 27, 2009 7:50 pm
Re: header files in C++
Thanks Neo.