c++ IO的继承结构

#include <stdio.h>
#include <iostream>//cin,cout
#include <sstream>//ss transfer.
#include <fstream>//file
#include "myclass.h"

using namespace std;

//io_s,基本的输入输出
//istream,ostream,从io_s中继承. 而iostream又继承2个,方便使用.
//fstream,ifstream,ofstream .又分别从上面3个继承.使用它们的输入输出方法,并扩展了对文件的处理.
//sstream,isstream,osstream ,和fstream一样.也分别继承istream,ostream,使用它们的输入输出方法,不过是从内存到内存。如从字符串到流,从流到各种类型(应该是吧).用于数据转换,分割.等.

int main()
{
    string line = "1 2 3 4 5";
    stringstream ss(line);

    string temp2;

    while(ss>>temp2)
    {
        cout<<temp2<<endl;
        temp2="";
    }
    ss.clear();//这里还清除了哨兵.所以从第一个输入.
    ss<<"abc";

    cout<<ss.str()<<endl;
    ss.str("");


    return 0;
}
原文地址:https://www.cnblogs.com/lsfv/p/6010526.html