Game Development Community

Should all objects be pointers?

by Ben Heath · in Technical Issues · 10/10/2004 (7:42 pm) · 0 replies

Hey there ev'rybody! Que paso, gumba?

So I'm on this project of mine and the idea pops into my head that, maybe, anytime I need an object/table/structure inside of another, I should just put a pointer to it instead. I figured it was good enough to ask and here I am. So, should all objects inside other objects (such as a position vector inside a game actor) be accessed through pointers?

It's obvious that this would have some challenges associated with it. What immediately comes to mind is a conceptually columnar memory structure where you have all your vectors in a big array or whatever, all your actors in another beside it, etc. You wouldn't need that for everything but that's generally how things could work. These could be reused throughout the program's lifetime, though problems could arise when objects start getting shared.

I mean, it's not a new trick or anything. That's exactly how a lot of people do it. I just want to know if it's really the best way.

Sincerely,
Benjamin Heath