Embracing additional C++ features promoting safety
As we have seen through 20 previous chapters of programming, C++ is an extensive language. We know that C++ has great power and that we can do nearly anything in C++. As object-oriented C++ programmers, we have seen how to adopt OO designs, with the goal of making our code more easily maintainable.
We have also gained a lot of experience utilizing raw (native) pointers in C++, primarily because raw pointers are very pervasive in existing code. You truly need experience and facility in using native pointers for when the need arises. In gaining this experience, we have seen firsthand the pitfalls we may encounter with mismanagement of heap memory – our programs may have crashed, we may have leaked memory, overwritten memory accidentally, left dangling pointers, and so on. Our first order of business in this chapter was to prefer using smart pointers in newly created code – to promote safety in C++.
Now, we will explore...