c++ 杂谈 4

关于类的作用域
public 都可以访问
private只能大括号的内部访问
protected继承关系的可以访问
friend可以在大括号的外部访问private
io流输入和输出
下面就是该函数自定义的输入
在.h文件中先声明
friend ostream& operator << (ostream&os,const Complex &x);
在.cpp文件内部


输入完成以后需要进行缓存区的清空
cin.ignore(numeric_limits<std::streamsize>::max(), '\n');
用于清空缓存区的脏数据
文件操作
一次性把大的文件块加载进来的

文件操作的步骤
打开文件用于读和写open; 加载到内存中间去
检查打开是否成功fail
读或者写 read,write
检查是否读完EOF(end of file)判断是否读写完毕
使用完文件后关闭文件close

抽象模型


版权声明: 本文为 InfoQ 作者【菜鸟小sailor 🐕】的原创文章。
原文链接:【http://xie.infoq.cn/article/0499fd0f867effff3eee6983c】。未经作者许可,禁止转载。
评论