哪里可以获得iostream.h

nod*_*nja 10 linux debian makefile g++

我正在尝试在Linux中制作一些东西,但它抱怨它无法找到iostream.h.我需要安装什么来获取此文件?

Joh*_*web 11

此标准标题的正确名称iostream没有扩展名.

如果您的编译器仍然无法找到它,请尝试以下操作:

find /usr/include -name iostream -type f -print
Run Code Online (Sandbox Code Playgroud)

...按照编译器的文档将其添加到include路径中.

  • g ++和任何标准C ++编译器应自动找到C ++标头,而无需指定其位置;实际上,从理论上讲,C ++标准允许“ <iostream>”的解析方式实际上不涉及名为“ iostream”的文件(即,允许编译器将名称映射到所需的任何名称,只要它提供所需的必要标准库类和函数)。 (2认同)

Mic*_*yan 10

标头<iostream.h>是一个过时的标题,从C++开始标准化为ISO C++ 1998(它来自C++ Annotated Reference Manual).标准C++标头是<iostream>.两者之间存在一些细微差别,最大的区别是<iostream>将包含的内容放入命名空间std中,因此您必须使用"std ::"限定cin,cout,endl,istream等.有点像黑客(它是一个黑客,因为头文件永远不应该包含"使用"指令,因为它们完全违背命名空间的目的),你可以定义"iostream.h"如下:

#ifndef HEADER_IOSTREAM_H
#define HEADER_IOSTREAM_H

#include <iostream>
using namespace std; // Beware, this completely defeats the whole point of
                     // having namespaces and could lead to name clashes; on the
                     // other hand, code that still includes <iostream.h> was
                     // probably created before namespaces, anyway.

#endif
Run Code Online (Sandbox Code Playgroud)

虽然这与原始的过时标题不完全相同,但对于大多数用途来说这应该足够接近(即应该没有任何东西或者很少需要修复的东西).