/*ca72a_c++_标准IO库:面向对象的标准库
继承:基类-》派生类
3个头文件
9个标准库类型
IO对象不可复制或赋值

ofstream, f--file,文件输出流
ostringstream,o--输出,string字符串输出流
iostream--输入输出流

istringstream,i-输入,string字符串输入流
ifstream,i--输入,f--file,文件输入流

stringstream--字符串输入输出流, <sstream> ////字符串输入输出流头文件
fstream--文件输入输出流

*/

 /*ca72a_c++_标准IO库:面向对象的标准库
继承:基类-》派生类
3个头文件
9个标准库类型
IO对象不可复制或赋值 ofstream, f--file,文件输出流
ostringstream,o--输出,string字符串输出流
iostream--输入输出流 istringstream,i-输入,string字符串输入流
ifstream,i--输入,f--file,文件输入流 stringstream--字符串输入输出流, <sstream> ////字符串输入输出流头文件
fstream--文件输入输出流 */ #include <iostream>
#include <fstream>
#include <sstream> ////字符串输入输出流头文件 using namespace std;
//void print(std::ofstream of)
//{
// cout << "test!" << endl;
//}
void print(std::ofstream &of)//传递引用
{
cout << "ofstream test" << endl;
}
ofstream& print1(std::ofstream &of)//传递引用
{
cout << "ofstream test" << endl;
std::ofstream of2;
return of2;//返回引用是可以的, ofstream&
} void foo(ostream& os)
{
cout << "test ostream" << endl;
//os << "test ostream" << endl;
} int main()
{
//cout是ostream输出流对象
//cout都是在std名称空间里面。std::cout,std::endl;,std::cin
cout << "hello world!" << endl;
fstream fs;//文件输入输出流
//或者。std::fstream std::stringstream ss;//字符串输入输出流 std::ofstream out1, out2;
//out1=out2;//错误。IO对象不可复制或赋值
//print(out1);//错误。IO对象不可复制或赋值,可以传参数与引用
print(out1);//可以传参数与引用 //vector<ofstream> vec;//不能用容器 foo(cout);//传递cout,cout是ostream cout << "ofstream test!!!" << endl;
std::ofstream ofs;
foo(ofs);// foo(ostream& os) osstream是基类,所以也可以接受它的派生类,ofstream ostringstream oss;
foo(oss);// foo(ostream& os) osstream是基类,所以也可以接受它的派生类,ostringstream
return ;
}

最新文章

  1. Mybatis XML配置
  2. Masonry介绍与使用实践:快速上手Autolayout
  3. sqlserver 2005 数据误删恢复
  4. String空值判定
  5. TEX学习笔记
  6. Winform以任意角度旋转PictureBox中的图片的方法
  7. 基于网格的波动方程模拟(Wave equation on mesh)附源码
  8. CodeForce---Educational Codeforces Round 3 D. Gadgets for dollars and pounds 正题
  9. 提交表单时的等待(loading)效果
  10. maven 编
  11. Multidimensional Arrays
  12. Apriori算法-java
  13. LeetCode之“数学”:Plus One
  14. iview源码解析(1)
  15. 05 - json转成树状结构
  16. hive资料
  17. 2.3 UML活动图
  18. QWebEngine_C++_交互
  19. LinUX系统ThinkPHP5链接MsSQL数据库的pdo_dblib扩展
  20. 20155207 实验四 《Android程序设计》实验报告

热门文章

  1. SpringCloud(二)- Consul介绍、安装、使用
  2. Multisim-74LS08\74LS02\74LS86逻辑功能仿真实验
  3. 树链剖分 (求LCA,第K祖先,轻重链剖分、长链剖分)
  4. eatwhatApp开发实战(三)
  5. [COCOS2DX-LUA]0-003.根据COCOS2DX热更新
  6. 关于安装Linux-centOS时遇到的问题
  7. 循序渐进VUE+Element 前端应用开发(6)--- 常规Element 界面组件的使用
  8. jchdl - RTL Event
  9. 基础数论——EXGCD
  10. 多线程与RunLoop