Design of std::ifstream class

后端 未结 3 1894
陌清茗
陌清茗 2020-12-11 20:21

Those of us who have seen the beauty of STL try to use it as much as possible, and also encourage others to use it wherever we see them using raw pointers and a

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-11 20:49

    My copy of the standard disagrees with you. It says both these are overloads:

    void open(const char* s, ios_base::openmode mode = ios_base::in);
    void open(const string& s, ios_base::openmode mode = ios_base::in);
    

    However, that copy of the standard is a draft of the next version of the standard, C++0x.

    The reason for this is that the iostreams library predates std::basic_string, and because the library designers didn't want someone to have to #include and all it's other associated baggage if they didn't want to use it.

提交回复
热议问题