Created
February 24, 2014 08:08
-
-
Save stevenRush/9183687 to your computer and use it in GitHub Desktop.
Simple strategy pattern example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class base_iterator | |
{ | |
private: | |
int * pointer; | |
protected: | |
virtual void advance(int *& pointer) = 0; | |
public: | |
base_iterator & operator++() | |
{ | |
advance(pointer); | |
} | |
}; | |
class iterator : base_iterator | |
{ | |
virtual void advance(int *& pointer) | |
{ | |
++pointer; | |
} | |
}; | |
class reverse_iterator : base_iterator | |
{ | |
virtual void advance(int *& pointer) | |
{ | |
--pointer; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment