PKU-程序设计实习-Myistream_iterator
2012-04-22 17:06
197 查看
#include <iostream> #include <string> #include <iterator> using namespace std; template<class T> class CMyistream_iterator { public: CMyistream_iterator(istream& istrm_): istrm(istrm_) { istrm >> val; }; void operator ++ (int) { istrm >> val; }; T operator * () { return val; } private: istream& istrm; T val; }; int main() { CMyistream_iterator<int> inputInt(cin); int n1,n2,n3; n1 = (* inputInt); //读入 n1] int tmp = * inputInt; cout << n1 << endl; inputInt ++; n2 = * inputInt; //读入 n2 inputInt ++; n3 = * inputInt; //读入 n3 cout << n1 << "," << n2<< "," << n3 << endl; CMyistream_iterator<string> inputStr(cin); string s1,s2; s1 = * inputStr; inputStr ++; s2 = * inputStr; cout << s1 << "," << s2 << endl; return 0; }
相关文章推荐
- PKU C++程序设计实习 学习笔记1
- PKU C++程序设计实习 学习笔记2 继承与派生
- C++基本要点复习--------coursera程序设计实习(PKU)的lecture notes
- PKU C++程序设计实习 学习笔记6 标准模板库STL
- PKU-程序设计实习-MySort函数
- PKU C++程序设计实习 学习笔记5 文件操作和模板
- PKU C++程序设计实习 学习笔记3 多态与虚函数
- 程序设计实习MOOC/第十五周编程作业/A:棋盘问题
- 北京大学信息科学技术学院计算机专业课程大纲选摘--程序设计实习
- 程序设计实习MOOC/第十三周编程作业/B:木材加工(NOIP 2004)
- 程序设计实习MOOC / 继承和派生——编程作业 第五周程序填空题1
- 程序设计实习课(0)资源链接
- 2017 程序设计实习之C++部分作业题汇总 - C:运算符重载
- 2017 程序设计实习之C++部分作业题汇总 - E:多态与虚函数
- 程序设计实习·笔记(引用)
- 程序设计实习·笔记(const常量)
- 程序设计实习MOOC / 程序设计与算法(一)第三周测验(2017冬季)2:求一元二次方程的根
- 2017 程序设计实习之C++部分作业题汇总 - F:模板 template
- c++ 11 异常处理 北京大学C++程序设计实习公开课
- OpenJudge程序设计实习之递归