C++ gives you, the programmer, more fine-grained access to memory than a language like Java. An old saying goes like this, “To whom much is give, much is expected.” So, because you have more control over memory, you have to take care to handle it appropriately. This means that if you dynamically allocate memory, you should de-allocate it when you’re done with it.
Here are a few YouTube videos that are similar to stuff I’ve talked about. But hearing the info explained a little differently might be helpful.
Basic Dynamic Allocation and Deallocation: Video
Memory Leaks and Dangling Pointers: Video (The writing is a little bit hard to read, but it is a good explanation)
Pointers to Pointers: Video (Same issue as above, but good expl).
Speak Your Mind