Summary
In this bonus chapter, we have added to our objective of becoming indispensable C++ programmers by understanding the importance of programming safely in C++. After all, our primary goal is to create robust and easily maintainable code. Incorporating safe programming practices will help us achieve this goal.
We have reviewed concepts seen throughout the book, as well as related ideas that culminate in adopting a set of core programming guidelines to ensure safer coding practices.
First, we reviewed smart pointers, examining three types from the Standard C++ Library, namely unique_ptr
, shared_ptr
, and weak_ptr
. We understand that these classes employ the RAII idiom by providing wrappers to allocate and deallocate heap memory safely on our behavior in well-tested standard library classes. We put forth a guideline: always prefer smart pointers in newly created code.
Next, we reiterated a variety of programming practices that we have seen throughout the book that we can...