Chapter 28

Incorporating Design Techniques and Frameworks

WHAT’S IN THIS CHAPTER?

  • An overview of C++ language features that are common but involve easy-to-forget syntax
  • What the double dispatch technique is and how to use it
  • How to use mix-in classes
  • What frameworks are

One of the major themes of this book has been the adoption of reusable techniques and patterns. As a programmer, you tend to face similar problems repeatedly. With an arsenal of diverse approaches, you can save yourself time by applying the proper technique to a given problem.

A design technique is a standard approach for solving a particular problem in C++. Often, a design technique aims to overcome an annoying feature or language deficiency. Other times, a design technique is a piece of code that you use in many different programs to solve a common C++ problem.

This chapter focuses on design techniques — C++ idioms that aren’t necessarily built-in parts of the language, but are nonetheless frequently used. The first part of this chapter covers the language features in C++ that are common but involve easy-to-forget syntax. Most of this material is a review, but it is a useful reference tool when the syntax escapes you. The topics covered include:

  • Starting a class from scratch
  • Extending a class with a subclass
  • Throwing and catching exceptions
  • Reading from a file
  • Writing to a file
  • Defining a template class

The second part of this chapter focuses on higher-level techniques that build upon C++ language features. ...

Get Professional C++, Second Edition 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.