Can anyone tell me why we use pointers
Because it already exists in the world, we want a pointer to that. Not using a pointer would mean making our own on the stack (which can’t happen, explained below) or a copy of it.
Game objects need to be created dynamically when the game starts which requires dynamic memory allocation. When you do that you are returned a pointer to that memory location, so everything that is spawned in the game world will be a pointer.
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.