How to include header files in Visual Studio 2008?

后端 未结 4 885
感动是毒
感动是毒 2021-02-14 18:03

I am currently trying to compile a simple program that includes two header files. I see them in the Solution Explorer, where I included them through \"include existing files\".

4条回答
  •  面向向阳花
    2021-02-14 18:33

    You said the file is in the "headers" folder. This could either mean the headers filter or an actual headers directory on the filesystem. When including a file from your own project you need to specify the path from the file you're including into. So, if you had something like so:

    src/main.cpp
    include/my_object.h
    

    You would use #include "../include/my_object.h" in main.cpp.

    That's for directories. The folders you see in your project are called filters and have absolutely no relation to the directory structure of your project unless you force it to. You need to be paying attention to what the structure looks like in windows explorer to ascertain what path to use in an include statement.

提交回复
热议问题