In this recipe, we will learn how to typecast using std::unique_ptr and std::shared_ptr. Typecasting allows you to convert one type into another. This recipe is important as it demonstrates the proper way of handling typecasting with std::unique_ptr and std::shared_ptr when attempting to convert the smart pointer's type (for example, when upcasting or downcasting with virtual inheritance).
Typecasting with smart pointers
Getting ready
Before beginning, please ensure that all of the technical requirements have been met, including installing Ubuntu 18.04 or higher and running the following in a Terminal window:
> sudo apt-get install build-essential git cmake
Once you have done this, open a new Terminal. We will use...