O'Reilly logo

Professional C++ by Scott J. Kleper, Nicholas A. Solter

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 25. Incorporating Techniques and Frameworks

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.

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. These techniques offer a better way to accomplish everyday programming tasks. Topics include:

  • Smart pointers with reference counting

  • The double-dispatch technique

  • Mix-in classes

Many of the previous chapters referred to these concepts without providing detailed code examples. In this chapter, you will see concrete examples of these concepts with code that you can use in your programs.

This chapter concludes with an introduction to frameworks, a coding technique that greatly eases the development of large applications.

"I Can ...

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