C++ #include <iostream.h> 和 #include <iostream> 之间的区别是什么?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15680190/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-27 19:38:54  来源:igfitidea点击:

What is the différence between #include <iostream.h> and #include <iostream>?

c++iostream

提问by Joseph Mansfield

What is the difference between

之间有什么区别

#include <iostream.h>

#include <iostream.h>

and

#include <iostream>

#include <iostream>

?

?

回答by Joseph Mansfield

Before C++ was even standardised, the I/O library was developed as <iostream.h>. However, that header has never been a standard C++ header. Some older compilers continued to distribute the <iostream>header also as <iostream.h>. Use <iostream>because it is guaranteed by the standard to exist.

在 C++ 甚至标准化之前,I/O 库被开发为<iostream.h>. 但是,该头文件从来都不是标准的 C++ 头文件。一些较旧的编译器继续将<iostream>标头也作为<iostream.h>. 使用<iostream>是因为标准保证它存在。

It's worth noting that the only standard headers that end with .hare the C standard library headers. All C++ standard library headers do not end with .h.

值得注意的是,唯一.h以 C 标准库头文件结尾的标准头文件。所有 C++ 标准库头文件都不以.h.

回答by StepUp

<iostream>is the usual header

<iostream>是通常的标题

<iostream.h>is the old header, not longer supported by some compilers

<iostream.h>是旧头文件,某些编译器不再支持

回答by Claudio

It just depends on the name of the file provided by your toolchain. Some (old) compilers use .h files. Modern compilers usually use (without the .h extension).

它只取决于您的工具链提供的文件的名称。一些(旧)编译器使用 .h 文件。现代编译器通常使用(没有 .h 扩展名)。