22.1 — Introduction to smart pointers and move semantics
Consider a function in which we dynamically allocate a value: void someFunction() { Resource* ptr = new Resource(); // Resource is a struct or class // do stuff with ptr here delete ptr; } Although the above code seems fairly straightforward, it’s fairly easy to forget to deallocate ptr. Even …