将 cout 的 flag 保存到变量, 以便修改后的恢复 ostream::fmtflags old = cout.flag() ; // 无参将返回当前 flag 值 cout.flag(old) ; // 恢复到原...
分类:
其他好文 时间:
2014-08-13 18:08:17
阅读次数:
265
class Int
{
friend ostream& operator<>(istream& is, Int& i);
friend bool operator<(const Int& a, const Int& b);
private:
int value;
public:
...
分类:
其他好文 时间:
2014-08-12 22:07:54
阅读次数:
273
从今天开始在博客里写C++primer的文字。主要以后面的习题作业为主,会有必要的知识点补充。本人也是菜鸟,可能有不对之处,还望指出。前期内容可能会比较水。1.1略1.2略1.3cin和cout分别是istream和ostream的对象。#includeusing namespace std;int...
分类:
编程语言 时间:
2014-08-12 21:50:14
阅读次数:
365
//25...9.4.
//4.71.3..6
//8.34.759.
//3.8.7..69
//.1.3.24..
//5.49.6.83
//9.6.3.7.8
//.3.6.8.1.
//1.2.9.6.4
struct node
{
node(int r,int c):row(r),col(c) {}
friend ostream& operator <<(ostr...
分类:
其他好文 时间:
2014-08-02 15:31:53
阅读次数:
272
Sales_item.h#ifndef SALES_ITEM_H#define SALES_ITEM_H#include#includeusing namespace std;class Sales_item{ friend ostream& operator>(istream &is,Sal...
分类:
其他好文 时间:
2014-07-31 09:37:26
阅读次数:
237
C++的流插入运算符“>”是C++在类库中提供的,所有C++编译系统都在类库中提供输入流类istream和输出流类ostream。cin和cout分别是istream类和ostream类的对象。在类库提供的头文件中已经对“>”进行了重载,使之作为流插入运算符和流提取运算符,能用来输出和输入C++标准...
分类:
编程语言 时间:
2014-07-30 23:25:25
阅读次数:
678
C++ 语言并未定义任何输入输出(IO)语句,取而代之,包含了一个全面的标准库(iostream)来提供IO机制(以及很多其他设施)。iostream库包含两个基础类型istream和ostream,分别表示输入流核输出流。一个流就是一个字符序列,是从IO设备读出或写入IO设备的。术语“流”想要表达...
分类:
其他好文 时间:
2014-07-30 17:11:23
阅读次数:
220
《C++ Primer Plus》学习笔记11
第17章 输入、输出和文件
主要内容:
1)C++角度的输入和输出
2)iostream类系列
3)重定向
4)ostream类方法
5)格式化输出
6)istream类方法
7)流状态
8)文件I/O
9)使用ifstream类从文件输入
10)使用ofstream类输出到文件
11)使用fstream类进行文件输...
分类:
编程语言 时间:
2014-07-25 11:25:31
阅读次数:
318
1、cin>>s; s可以是:string s、char s[];
这个是ostream中的函数,遇到‘ ’(空格) , '\n'(换行),就会自动结束,因此如果用cin读取字符串,那么这个字符串中不能含有空格和换行。
cin因为不识别空格和换行,因此如果在输入字符串的时候,在字符开始处输入了空格或换行,没有任何影响。
#include
#include
#include
using...
分类:
编程语言 时间:
2014-07-24 11:36:13
阅读次数:
220
平时总遇到将数据写到txt中的情况,尤其是在调试程序看中间结果时,所以将代码保存下来,方便以后应用:
ofstream outfile;
string InitialFileName("Initial.txt");
string NewFileName("New.txt");
outfile.open(InitialFileName, ostream::app); /*...
分类:
编程语言 时间:
2014-07-16 10:46:58
阅读次数:
193