header file

Can any one tell me what is header file and give me some examples .I will be thankfull.
A header file is supposed to store the definitions of a class and any function prototypes.

For example:
.h file
1
2
void func1();
int func2(int a, int b);


.cpp file
1
2
3
4
5
6
7
void func1() {
    // do stuff
    return;
};
int func2(int a, int b) {
    return a - b;
};
Last edited on
what is the difference between .h header file and cpp header file ?>
.cpp is not a header file, it is a source file, and is the part of the program that is actually compiled. It contains the implementation of non-template functions and methods.

.h files are just the prototypes of non-template methods and functions, and well as the definitions of classes. It is used mainly so other .cpp files can tell what functions will be defined in other .cpp files.
In the examples above there is no .h in the header files ?
One small note on terminology: declarations are typically located in the header file and definitions, or implementations, are generally located in the source file.
Header file
1
2
#include <iostream>
#include <myfile.h> 

Topic archived. No new replies allowed.