strategy algorithm example using c++