Where to get iostream.h

前端 未结 3 877
深忆病人
深忆病人 2020-11-28 15:44

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条回答
  •  一整个雨季
    2020-11-28 16:25

    The header 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 . There are some minor differences between the two, with the biggest difference being that 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 
    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  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).

提交回复
热议问题