Summary
In this chapter, we have furthered our goal of becoming better C++ programmers by expanding our programming repertoire by embracing another design pattern. We have explored the Singleton pattern by first employing two simple approaches, and then a paired-class implementation using Singleton
and SingletonDestroyer
. Our approach uses inheritance to incorporate our Singleton’s implementation into our Target class. Optionally, we incorporate a useful, existing base class into our Target class using multiple inheritances.
Making use of core design patterns, such as the Singleton pattern, will help you more easily reuse existing, well-tested portions of code in a manner understood by other programmers. By employing familiar design patterns, you will be contributing to well-understood and reusable solutions with avant-garde programming techniques.
We are now ready to continue onward with our final design pattern in Chapter 20, Removing Implementation Details Using the...