When the program size becomes larger, a program is organized with multiple files to facilitate the organization of production. This way, you do not have to compile all the code every time, but only once. After the compilation of the resulting target file to save, and later when necessary to transfer it directly to the program's target file to connect.
A common practice in C + + is to separate out a header file. The benefits of proper use of header files include: Support for local compilation of code, especially for classes and member functions, to ensure that all files use the same declaration for a given entity, and that only the header file needs to be updated when the declaration needs to be modified. When using a header file, the header file is used only for declarations, not definitions, and header files generally contain declarations that support the class definitions and variables and functions required to compile separately. In addition, some const objects are defined in the header file. The member function definition for a class has only one exception in the header file, which is that the built-in (inline) member function needs to be defined in the header file.
Examples can be referred to: http://www.cnblogs.com/jiu0821/p/4395738.html
Multi-file organization of C + + programs