C++ #include <[filename]> 但#include <string> 不是文件名

C++ #include <[filename]> but #include <string> is not a filename

重复:
When can you omit the file extension in an #include directive?


发现后觉得自己聪明了一点:
What is the difference between #include <filename> and #include "filename"?

但在我的代码中我使用 #include <string>.
string 不是有效文件名,尖括号未放在 "".

这是包含其他文件的第三种方式还是我必须如何理解它?
也就是说,什么是<string>?

string is not a valid filename

是的。头文件的名字就是字面上的string。搜索您的包含路径,e。 g.:

find /usr/include /usr/local/include -name "string"

你会得到一些结果。

什么是文件扩展名?

它们是一些 OS(通常是 windows)自己的方式来识别文件类型以使用其默认应用程序打开它。 而 Mac 和 Linux 使用 MIME 来识别文件类型。

“MIME”代表 Multipurpose Internet 邮件扩展

所以在这种情况下,图书馆是一样的。它是使用 MIME 类型制作的,因为我们的 windows os 除了使用特定的 IDE 之外不需要打开该文件,所以我们从文件识别问题中解脱出来。