© Dmitri Nesteruk 2018
Dmitri NesterukDesign Patterns in Modern C++https://doi.org/10.1007/978-1-4842-3603-1_22

22. Strategy

Dmitri Nesteruk1 
St. Petersburg, Russia
Suppose you decide to take an array or vector of several strings and output them as a list,
  • just

  • like

  • this

If you think about the different output formats, you probably know that you need to take each element and output it with some additional markup. But in the case of languages such as HTML or LaTeX , the list will also need the start and end tags or markers. The processing of lists in either of these formats is at the same time similar (you need to output each item) and different (the way the items are output). Each of these can be handled with a separate Strategy.

We can formulate ...

Get Design Patterns in Modern C++: Reusable Approaches for Object-Oriented Software Design now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.