2013-01-02 407 views
0

我使用GCC 4.6.3:致命错误:iostream.h:没有这样的文件或目录

[email protected]:~$ g++ --version 
g++ (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3 

我的计划会导致以下编译错误:

[email protected]:~$ g++ ArrayInput.cpp 
ArrayInput.cpp:1:21: fatal error: iostream.h: No such file or directory 

如何解决它?

+0

通常要使用''包括。也许他们已经在默认包含路径? –

+0

解决问题并重新编译我得到这个错误: - gourab @ gourab-RV509:〜$ g ++ ArrayInput.cpp ArrayInput.cpp:在函数'int main()': ArrayInput.cpp:5:2:error: 'cout'未在此范围内声明 ArrayInput.cpp:5:2:note:建议的替代方案: /usr/include/c++/4.6/iostream:62:18:note:'std :: cout' ArrayInput。 cpp:8:5:error:'cin'未在此范围内声明 ArrayInput.cpp:8:5:note:建议的替代方案: /usr/include/c++/4.6/iostream:61:18:note:' std :: cin' –

+0

@ grv.giit您正在使用哪本书? – asheeshr

回答

2

你想包括iostreamiostream.h存在于Stroustrup的C++:

The original iostream library was written to challenge the claim that a terse, type safe I/O system needed special language support. 1 It was developed at Bell Labs by Bjarne Stroustrup and shipped with the original C++ compiler, CFront and described in the first edition of Stroustrup's The C++ Programming Language. This version of the iostream library lived in the headers iostream.h, fstream.h and so on.

标准C++有头无.H,所以要:

#include <iostream> 

这里是一个article讨论这件事。

+1

不推荐使用;它根本不存在于标准C++中,并且_never did_。 –

11

iostream.h已经在C++中,因为一段时间的语言是在1998年

这比十五年前标准化回来之前不存在。

执行以下操作:

  • 扔掉你的阅读材料
  • 得到一个decentbook
  • #include <iostream>没有.h
相关问题