O'Reilly logo

Professional C++, Second Edition by Scott J. Kleper, Nicholas A. Solter, Marc Gregoire

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required