2013-01-02 134 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
相關問題