4 ms·
> Next Up: Smart Pointers > RAII is a powerful technique but what we've seen so far is only a partial solution. Things are (mostly) fine when working with obje
by williamcotton 2y ago
> Next Up: Smart Pointers
> RAII is a powerful technique but what we've seen so far is only a partial solution. Things are (mostly) fine when working with objects but if we want to work with pointers, as in our Rectangle example, then we need to implement custom copy constructors, copy assignment operators, etc. if we want them to be safe. This is true even if we want to store on object on the heap but have a pointer on the stack. In the next post I'll be covering a technique called "smart pointers" that helps address these problems.