Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iterator>
- #include <string>
- using namespace std;
- class myiterator : public iterator<input_iterator_tag, string>
- {
- string p;
- unsigned int i;
- public:
- myiterator(string x)
- {
- p = x;
- i = 0;
- }
- bool hasNext()
- {
- return i<p.length();
- }
- char next()
- {
- int k = i;
- i++;
- return p[k];
- }
- void add(string x)
- {
- p += x;
- }
- void startPosition()
- {
- i = 0;
- }
- void remove()
- {
- }
- };
- int main () {
- string numbers = "500154821254";
- myiterator it(numbers);
- it.next();
- it.startPosition();
- it.add("aaaa");
- while(it.hasNext())
- cout << it.next();
- cout << "\n";
- return 0;
- }
Add Comment
Please, Sign In to add comment