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

22. Strategy

Dmitri Nesteruk1 
(1)
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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.