我知道关于 <header>
之间的区别的问题和 <header.h>
之前有人问过。阅读这些答案后,我发现了以下差异
- 当然
iostream.h
已弃用,新的符合标准的编译器不支持它 -
iostream.h
不包含std
中的所有内容命名空间,不使用模板。
好的。
但是,在阅读了几本书和一些答案(如 this )之后,我推断出 #include<iostream.h>
在我们的程序中包含一个名为 iostream.h 的特定文件 而#include<iostream>
甚至根本不需要映射到文件。它只是保证属于 iostream
的所有内容图书馆包含在我们的计划中。我说得对吗?
最佳答案
文件不需要“系统”头。包含使用 <>
是这样指定的:
C++11 16.2 [cpp.include]/2: 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.
因此,如果实现者认为这是一个好主意,则可以在不加载和预处理文本文件的情况下使用实现已知的 header 声明(可能包括也可能不包括当前和/或过时的标准库 header ) .
包含 ""
将首先搜索一个文件(在实现定义的地方),然后回退到 <>
如果失败。
关于c++ - 这是 iostream.h 和 iostream 之间的区别吗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26976962/