Where to get iostream.h

2020-01-25 11:17发布

I'm trying to make something in Linux, but it complains that it can't find iostream.h. What do I need to install to get this file?

3条回答
放我归山
2楼-- · 2020-01-25 11:26

The correct name of this standard header is just iostream without an extension.

If your compiler still cannot find it, try the following:

find /usr/include -name iostream -type f -print

...and add it to your include path, following your compiler's documentation.

查看更多
乱世女痞
3楼-- · 2020-01-25 11:37

The header <iostream.h> is an antiquated header from before C++ became standardized as ISO C++ 1998 (it is from the C++ Annotated Reference Manual). The standard C++ header is <iostream>. There are some minor differences between the two, with the biggest difference being that <iostream> puts the included contents in namespace std, so you have to qualify cin, cout, endl, istream, etc. with "std::". As somewhat of a hack (it is a hack because header files should never contain "using" directives as they completely defeat the purpose of namespaces), you could define "iostream.h" as follows:

#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

While this is not exactly identical to the original antiquated header, this should be close enough for most purposes (i.e. there should be either nothing or very few things that you will have to fix).

查看更多
爷的心禁止访问
4楼-- · 2020-01-25 11:44

I need to compile partport on debian and had problems (centos 4.5 works fine) I did this without no success ln -s /usr/include/c++/4.5/iostream /usr/include/c++/4.5/iostream.h

I discover that iostream.h provides from c++ and I found it on centos 4.5

so I copied from centos 4.5 to ubuntu natty the file iostream.h and it worked
scp root@ip.centos-4.5:/usr/include/c++/3.3.4/backward/iostream.h /usr/include/c++/4.5/iostream.h

查看更多
登录 后发表回答