c++ - 这是 iostream.h 和 iostream 之间的区别吗

标签 c++ syntax include language-lawyer

我知道关于 <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/

相关文章:

java - 为什么 System.out.print() 不工作?

C++ Windows 命令提示符 C1083 "Cannot open include file: ' Magick++.h' No such file or directory"

c++ - 使用 Matlab Compiler 将 MATLAB .m 文件转换为 .mex 文件

C++ UDP 双向客户端/服务器传送

syntax - 这个 elm 构造 : type X = X {. ..} 的名称是什么?

php - Smarty 3 如何与 Zend Framework 2 一起使用?

PHP Include 不显示页眉和页脚

c++ - 使用具有外部依赖关系的库构建多个子项目

c++ - C结构指针解引用速度

mysql - 重复键更新后的多次插入