IO类
IO库类型和头文件
注意宽字符版本的都是在前面加个w,比如:wistream,wostream,wiostream,wifstream。。。
IO对象无拷贝或赋值
ofstream out1, out2;
out1=out2; //错误:不能对流对象赋值
ofstream print(ofstream); //错误不能初始化ofstream参数
out2=print(out2); //错误:不能拷贝流对象
刷新输出缓冲区
cout<<"hi!"<<endl; //输出hi和一个换行,然后刷新缓冲区
cout<<"hi!"<<flush; //输出hi,然后刷新缓冲区,不附加任何额外字符
cout<<"hi!"<<ends; //输出hi和一个空字符,然后刷新缓冲区
unitbuf操纵符
cout<<unitbuf; //所以输出操作后都会立即刷新缓冲区
//任何输出都立即刷新,无缓冲
cout<<nounitbuf; //回到正常的缓冲方式
关联输入和输出流
cin.tie(&cout); //将cin和cout关联起来
//old_tie指向当前关联到cin的流
ostream *old_tie=cin.tie(nullptr); //cin不在与其他流关联
//将cin与cerr关联;这不是一个好主意,因为cin应该关联到cout
cin.tie(&cerr); //读取cin会刷新cerr而不是cout
cin.tie(old_tie); //从建cin和cout间的正常关联
PS:这章流的开头,说实话我不太清楚,你说看懂了没?看懂了,理解了没,没理解透,会用吗?完全不会!!!!不过等我慢慢摸索,相信我一定可以搞定他们的!!