Possible Duplicate:
What is the difference between #include <filename> and #include “filename”?
尖括号< >
有什么区别和双引号 " "
同时在 C++ 中包含头文件?
我的意思是应该包含哪些文件,例如:#include <QPushButton>
以及要包含哪些文件,例如:#include "MyFile.h"
???
最佳答案
它依赖于编译器。也就是说,一般使用 "
将当前工作目录中的 header 优先于系统 header 。 <>
通常用于系统头文件。从到规范(第 6.10.2 节):
A preprocessing directive of the form
# include <h-char-sequence> new-line
searches a sequence of implementation-defined places for a header identified uniquely by the specified sequence between the
<
and>
delimiters, and causes the replacement of that directive by the entire contents of the header. How the places are specified or the header identified is implementation-defined.A preprocessing directive of the form
# include "q-char-sequence" new-line
causes the replacement of that directive by the entire contents of the source file identified by the specified sequence between the
"
delimiters. The named source file is searched for in an implementation-defined manner. If this search is not supported, or if the search fails, the directive is reprocessed as if it read# include <h-char-sequence> new-line
with the identical contained sequence (including
>
characters, if any) from the original directive.
所以在大多数编译器上,使用""
首先检查您的本地目录,如果找不到匹配项,则继续检查系统路径。使用 <>
以系统标题开始搜索。
关于c++ - 在 C++ 中包含头文件时尖括号 < > 和双引号 ""之间的区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3162030/