What this book covers
Chapter 1, Understanding Basic C++ Assumptions, provides a concise review of basic language features that are assumed knowledge within the book. Existing programmers can quickly grasp the language basics reviewed in this first chapter.
Chapter 2, Adding Language Necessities, reviews non-OO features that are critical C++ building blocks: const
qualifiers, function prototyping (default values), and function overloading.
Chapter 3, Indirect Addressing – Pointers, reviews pointers in C++, including memory allocation/deallocation, pointer usage/dereferencing, usage in function arguments, void pointers, and introduces the concept of smart pointers.
Chapter 4, Indirect Addressing – References, introduces references as an alternative to pointers, including initialization, function arguments/return values, and const qualification.
Chapter 5, Exploring Classes in Detail, introduces OOP by first exploring OO and the concepts of encapsulation and information hiding, and then covers class features in detail: member functions, the this
pointer, access labels and regions, constructors, destructor, and qualifiers on data members and member functions (const
, static
, and inline
).
Chapter 6, Implementing Hierarchies with Single Inheritance, details generalization and specialization using single inheritance. This chapter covers inheriting members, the use of base class constructors, inherited access regions, order of construction/destruction, final
classes, as well as public versus private and protected base classes, and how this changes the meaning of inheritance.
Chapter 7, Utilizing Dynamic Binding through Polymorphism, describes the OO concept of polymorphism and then distinguishes operation from method, details virtual functions and runtime binding of methods to operations (including how the v-table works), and differentiates the use of virtual
, override
, and final
.
Chapter 8, Mastering Abstract Classes, explains the OO concept of abstract classes, their implementation using pure virtual functions, the OO concept of an interface and how to implement it, as well as up and down casting within a public inheritance hierarchy.
Chapter 9, Exploring Multiple Inheritance, details how to use multiple inheritance as well as its controversy in OO designs. This chapter covers virtual base classes, diamond-shaped hierarchies, and when to consider alternate designs by examining the OO concept of a discriminator.
Chapter 10, Implementing Association, Aggregation, and Composition, describes the OO concepts of association, aggregation, and composition and how to implement each concept using pointers, sets of pointers, containment, and sometimes references.
Chapter 11, Handling Exceptions, explains how to try
, throw
, and catch
exceptions by considering many exception scenarios. This chapter shows how to extend an exception handling hierarchy.
Chapter 12, Friends and Operator Overloading, explains the proper use of friend functions and classes, and examines operator overloading (which may use friends) to allow an operator to work with user defined types in the same way it works with standard types.
Chapter 13, Working with Templates, details template functions and classes to genericize certain types of code to work with any data type. This chapter also shows how operator overloading can make selected code more generic for any type to further support the use of templates.
Chapter 14, Understanding STL Basics, introduces the Standard Template Library in C++ and demonstrates how to use common containers, such as list
, iterator
, deque
, stack
, queue
, priority_queue
, and map
. Additionally, STL algorithms and functors are introduced.
Chapter 15, Testing Classes and Components, illustrates OO testing methods using the canonical class form and drivers to test classes, and shows how to test classes related through inheritance, association, and aggregation. This chapter also shows how to test classes that utilize exception handling.
Chapter 16, Using the Observer Pattern, introduces design patterns overall and then explains the Observer pattern, with an in-depth example illustrating the components of the pattern.
Chapter 17, Applying the Factory Pattern, introduces the Factory Method pattern and showcases its implementation with and without an Object Factory. It also compares an Object Factory to an Abstract Factory.
Chapter 18, Applying the Adapter Pattern, examines the Adapter pattern, providing strategies and examples utilizing inheritance versus association to implement the pattern. Additionally, this chapter demonstrates a wrapper class as a simple Adapter.
Chapter 19, Using the Singleton Pattern, examines in detail the Singleton pattern with a sophisticated paired-class implementation. Singleton registries are also introduced.
Chapter 20, Removing Implementation Details Using the pImpl Pattern, describes the pImpl pattern, which is used to reduce compile-time dependencies within code. A detailed implementation is explored using unique pointers. Performance issues are explored relating to the pattern.
Chapter 21, Making C++ Safer, revisits topics covered throughout the book, with the intention of identifying core programming guidelines that can be used to make C++ a safer language for the development of robust software.
Assessments contains all the answers to the questions from every chapter.