I'm confuse on what .h files do and why you need. I'm guessing its where you put in all the libraries that you used. If you can tell me if I'm right or wrong that would be great.
I am not sure either. I know .h stands for header files. Past that I dont know anything.
I use .h for all my funtions. It helps me keep them apart from my main funtion. But I dont think it really matter the compiler. I have used .seeJackRun and .jakAndJill just to see if it would use the file. I also tryed using no extention. All three worked just fine. But it can get confusing to the user.
The .h is a suffix given to the certain libraries or header files in C. To keep the compatibility with those libraries, C++ allow you to use either the suffix .h or the prefix c before the name of the library.
1 2 3 4 5 6 7 8
// This is C++ code
#include <cstdio> // Nothing unusual in #include line
int main()
{
std::printf("Hello world\n"); // Nothing unusual in the call either
...
/* This is C code that I'm compiling using a C++ compiler */
#include <stdio.h> /* Nothing unusual in #include line */
int main()
{
printf("Hello world\n"); /* Nothing unusual in the call either */
...
}
The .h is a suffix given to the certain libraries or header files in C.
Partially correct.
.h - is extension of C header file
But compiler doesn't actually care about your file extensions and it is still common to use header files with extension ".h".
Header files are usually used for class and/or function declarations, for template classes and/or functions and for inline function definitions.
The most important thing about using header file is Encapsulation, and this is also one of the most important features of Object-Oriented Programming.
Using header file to save the declarations of class (only declarations, no definition of functions) and the variables that you wish to use in different source files.
Once you provide your class to the users, you can only provide the header file(including declarations of class, infomation about how to use this class and etc.) and the .obj file(the source code of .cpp file has been compiled and translated to machine language, the customer can not read your source code from .obj file, but your computer can understand it).
Because of that, your source code is totally safe, and the users can not read and change your source code, they can only use it.