Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class CustomIter {
- public:
- CustomIter(int index=0) : index(index) {}
- CustomIter &operator++() {
- cout << "Prefix" << endl;
- ++index;
- return *this;
- }
- CustomIter operator++(int) {
- CustomIter copy(index);
- ++index;
- cout << "Postfix" << endl;
- return copy;
- };
- int operator*() {
- return index;
- }
- private:
- int index;
- };
- int main()
- {
- CustomIter i;
- ++i;
- i++;
- for (CustomIter i; *i != 5; ++i)
- cout << *i << endl;
- for (CustomIter i; *i != 5; i++)
- cout << *i << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement