
string isn't the only type you get by including there is also wstring which is a wide character version. To add three bits of confusion to this confusion. So if you remember that #include isn't including the string class, but a file named string which contains the definition of the string class then you will be better off. C++ names the header files after the class that it contains and that can make the difference hazy. I guess the reason for the confusion is because you started off with C++, (but don't get me wrong, it isn't a bad thing). Where this sample may be seen as pointless it shows that by including struct.h both source1.cpp and source2.cpp get the structure definition without having to define it themselves. For example if you have 3 source files which use a structure you can either define that structure in all 3 source files or put that structure definition in a header and include it in the 3 source files. A good basic use for headers is to share information on types. If you think of a class as a blueprint then you wouldn't be too far wrong there either. For the class, it can be a bit more tricky.

So if you of a header as a box then you wouldn't be far wrong. On the other hand a class is esentially a user defined data type.

A header file is a file often used to contain definitions of functions, classes, structures etc. which can be included into a source file for it to use.
