031 山寨版istream_iterator
作者:互联网
#include <iostream>
#include <string>
using namespace std;
template <class T>
class CMyistream_iterator
{
// 在此处补充你的代码
public:
T a;
CMyistream_iterator(istream& cin){
cin >> a;
}
operator T *() {
return &a;
}
CMyistream_iterator & operator++(int ab) { //右侧++需要传无用int 类型参数
cin >> a;
return * this;
}
};
int main()
{
int t;
cin >> t;
while (t--) {
CMyistream_iterator<int> inputInt(cin);
int n1, n2, n3;
n1 = *inputInt; //读入 n1
int tmp = *inputInt;
cout << tmp << endl;
inputInt++;
n2 = *inputInt; //读入 n2
inputInt++;
n3 = *inputInt; //读入 n3
cout << n1 << " " << n2 << " " << n3 << " ";
CMyistream_iterator<string> inputStr(cin);
string s1, s2;
s1 = *inputStr;
inputStr++;
s2 = *inputStr;
cout << s1 << " " << s2 << endl;
}
return 0;
}
标签:iterator,int,cin,CMyistream,istream,inputInt,inputStr,031 来源: https://www.cnblogs.com/icefield817/p/15931151.html