I noticed that we were creating various pointers as references to objects like the barrel. I was wondering why don’t we ever free them inside the destructor of the class they’re being declared in? Is it because the barrel is created by the UE4 engine and clean up is left to the engine? What about pointers we declare ourselves with new
.
Also, from what I can recollect, isn’t keeping multiple instances of a pointer to the same object not ideal? I believe this is because keeping multiple pointers to the same object can be dangerous once the memory is freed. It’ll be difficult keeping track what has access to what pointer. Though in the case of this lecture it seems fine I believe since once the Tank is destroyed, so is the aiming component.
Thanks.