c ++ header file that contains the custom

In c ++ in a custom library by way of source code reuse in other projects, we need to add the appropriate header files, there are several ways to customize the header file that contains among other items:

  1. The custom library header files ( .h) as the source file ( .cpp) is copied to the current project folder, and then used in the project from the #include "headerfile.h"can (The disadvantage is that each new project must be copied to the header and source files, and if self custom library changes also re-copy the new files to its reliance projects)
  2. In the menu bar 项目-项目属性-配置属性-VC++目录-包含目录, add a custom header files define the path, then you can file as head contains the standard library, the use of #include <header.h>containing
  3. If you do not want every time an assignment file or directory that contains the project settings, just imagine using c ++ standard library header files, a #includeget, can be as follows:
    • One of the search path to find the compiler (here using iostreamthe path, the machine is D:\ProgramFiles\Microsoft Visual Studio 14.0\VC\include)
    • In which the new folder mypkg(separate header file system area)
    • In the new folder under a new Utilsfile, add a line of content#include "AbsolutePathToHeaderFile\utils.h
    • Then just use #include <mypkg\Utils>you can use a custom header fileutils.h
Published 28 original articles · won praise 14 · views 20000 +

Guess you like

Origin blog.csdn.net/liyunxin_c_language/article/details/103269805