![]() 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.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |