Pointers or copies?

Orgoton orgoton at mindless.com
Wed Dec 20 14:12:27 PST 2006


I'm making a game and I have to keep track of the objects in the game, which
inherit from a master object class called "objct". So I would make a class for
"baddie", "player" and such. Now, to draw them I have to keep track of their
existance, so, when one is created, it adds itself to the "frame queue" and
removes itself when it is deleted. To keep track of them I created a "queue"
class, which has a protected member called "objct *pters[]". It is an array of
pointers so when I recieve a new actor for the queue, I increase the array
size accordingly and on the next slot, just add it there. Simple. Now, the
queue class has a method called "add" and "remove" both of them take as
parameter "objct *target".

To sum it up and finally tell you my question the objct has in it's
constructor "framequeue.add(this);" and a correspondind "remove(this)".

Apparently, "this" is not a pointer... as the compiler claims: "function
queue.remoce (objct *target) does not match parameter types (objct)" and that
"cannot implicitly convert expression (this) of type objct to objct*". So,
does passing "this" create a copy of the object? How do I pass the pointer to
the object to the queue? Any other solution?



More information about the Digitalmars-d mailing list