Hi buddies,
I don't know how to understand the input and output iterators are based on _single pass_ algo.
Here is the code:
ifstream ifile("0123.txt"
; //file content is 0 1 2 3
istream_iterator<int, ptrdiff_t> r(ifile);
istream_iterator<int, ptrdiff_t> r(ifile);
++r;
++s;
cout<<*r<<endl;
cout<<*s<<endl;
(r==s)? cout<<"equal": cout<<"not equal";
cout<<endl;
How can I get the output as
2
3
equal
? Can any guru explain it to me?
How are they implemented under the hood?
Thanks a million!
I don't know how to understand the input and output iterators are based on _single pass_ algo.
Here is the code:
ifstream ifile("0123.txt"
istream_iterator<int, ptrdiff_t> r(ifile);
istream_iterator<int, ptrdiff_t> r(ifile);
++r;
++s;
cout<<*r<<endl;
cout<<*s<<endl;
(r==s)? cout<<"equal": cout<<"not equal";
cout<<endl;
How can I get the output as
2
3
equal
? Can any guru explain it to me?
How are they implemented under the hood?
Thanks a million!