Discussion: A Destructive Relationship
Execute the code to understand the output and gain insights into destructors and virtual functions.
We'll cover the following...
We'll cover the following...
Run the output
Now, it’s time to execute the code and observe the output.
Understanding the output
When we call draw(), the program only prints Button draw. But when unique_ptr goes out of scope, and the destructor is called, the program prints both Button destructor and Widget destructor. Why is that?
Virtual functions
A common technique for dynamic polymorphism is using virtual functions. We ...