C++: DestroyComponent crashes program.

Are you instantiating the object?


Anyway… when you do this:
arr[i].box_component = nullptr;

The garbage collector detects that the pointer does not point anywhere and will free the memory automatically.

Then I think there is not need to destroy the object. The GC will do it for you.

1 Like