Pointers or copies?
Chris Nicholson-Sauls
ibisbasenji at gmail.com
Wed Dec 20 14:44:56 PST 2006
Orgoton wrote:
> I haven't finished it yet. Well, each frame, the main engine will cycle through
> all the pointers on the queue with something like
>
> for (i=0; i<queue.size; i++) queue.next().draw();
>
> Or, to save up the callings
>
> queue.drawall()
>
> where all pointers would be called.
>
> I'm used to C++, sorry for the question about pointers and copies. That means I
> can just make something like
>
> objct objts[];
>
> and use it just like a pointer...
>
> void add (in objct target)
> { objts[objts.lenght-1]=target; }
>
> (on objct)
> this
> {queue.add(this);}
>
> and it'l work just fine without creating copies of the objects? (and spare me of
> memory problems along the way :P)
That's right. You could also use array concatenation (objts ~= target;) if you aren't
wanting to enforce a particular size. And since you plan to use this in a loop, it might
be worth taking a look at foreach.
-- Chris Nicholson-Sauls
More information about the Digitalmars-d
mailing list