Skip to content

Instantly share code, notes, and snippets.

@stevenRush
Created February 24, 2014 08:08
Show Gist options
  • Save stevenRush/9183687 to your computer and use it in GitHub Desktop.
Save stevenRush/9183687 to your computer and use it in GitHub Desktop.
Simple strategy pattern example
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