Text Stream:
有解析(parse)和格式化(format)的过程
Binary Stream:
无解析(parse)和格式化(format)的过程
自定义extractor:
全局函数
istream&
operator >> (istream& is, T& obj) {
//content
return is;
}
第一个参数是receiver
istream参数不可以const,因为流的position(当前读到的位置)
返回是istream:为了连续运算
cin >> a >> b >> c;
int get();
cin.get();
等许多运算函数。
自定义inserter
ostream&
operator << (ostream& is, const T& obj) {
//content
return os;
}
cout << a << b << c;
((cout << a) << b) << c;
自定义operator
ostream& manip(ostream& out) {
return out;
}
example:
ostream& tab(ostream& out) {
return out << ' \t';
}