smart pointers in C++
Smart Pointers To understand smart pointers we must understand normal pointers. By default, objects in C++ are placed on the stack. The stack is sequential, quick-access storage that also doesn’t have a ton of room. It is LIFO, like a pancake stack. The memory management is automatic. What do we do when we need more room? We go to the heap. The heap is dynamically allocated memory. That means that we choose when to use it, and when to release it. A pointer is how we put things on the heap. It’s an object in the stack that HAS A REFERENCE to a heap location. With raw pointers, we create them ourselves, and delete them ourselves. However, there is a risk of leaking memory caused by Freeing up heap memory that didn’t need to be freed Forgetting to free up heap memory Now, we get to smart pointers. These remove us from the responsibility of manually getting rid of memory, but they are still more effective than garbage collection in other lang...