|
||
|
GP Mailing List
ATXGPSIG List
|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: pointers
Did somebody already answer this? I have like 2000 messages on this and
3 other lists so I can't see all of the replies all that easily. Anyway,
onto your problem. You declare your variable WorldObjects as a pointer
which reserves x amount of ram (where x = sizeof(OBJECTP) * NumObjects), or
as NumObjects objects, however you prefer to think of it. So, you declare
this as an array in RAM (if I recall correctly, all non-pointers are stored
in the cache and all pointers are in RAM, thus the overhead of dereferencing
pointers, correct me if I'm mistaken), not as NumObjects pointers to
objects.
What does this mean? You would access each object exactly as any other
array object, using the '.' operator. The reason is that it's one pointer,
which happens to point to the array, not many pointers, which each point to
an object, as I explained above. I'm getting much to stringy, I think, so
here's the explanation in C++ speak:
//First it's declared.
OBJECTP * WorldObjects = new OBJECTP[NumObjects];
//And now the pointer's dereferenced, kind of, and we want the xth object
//in the memory that holds it.
WorldObjects[x].SomeFunctionOrVariable;
Can't think of anything else that could possibly help you, and I don't
even know if this helps you. Of course, I don't know everything and may
make mistakes, so tell me about some of them if there are any.
Mike Weber
>From: "Brian Holley" <comp_brain@hotmail.com>
>Reply-To: gameprogrammer@gameprogrammer.com
>To: gameprogrammer@gameprogrammer.com
>Subject: pointers
>Date: Fri, 08 Sep 2000 14:17:02 GMT
>
>Hey everybody.
>
>I'm having some problems with some work I'm trying to do with pointers.
>Basically I think it boils down to how I'm trying to reference a pointer to
>an array of pointers. I'm trying to do this:
>
>OBJECTP * WorldObjects = new OBJECTP[NumObjects];
>
>where OBJECTP is a pointer to my object struct and NumObjects in the number
>of objects in the scene. I trying to reference this array like this:
>
>WorldObjects[x]->...;
>
>my question is, is there a special notation I need to use? Because I think
>right now I'm discounting the fact that this is a POINTER to an array and
>not an array.
>
>Any help on this subject will be very much appreciated.
>Thanks.
>
>-Brian
>_________________________________________________________________________
>Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
>
>Share information about yourself, create your own public profile at
>http://profiles.msn.com.
>
>=================================================================
>The GameProgrammer.Com mailing list is for the open discussion
>of any topic related to the art, science, and business of
>programming games. This list is especially tolerant of beginners.
>We were all beginners once
>
>To SUBSCRIBE or UNSUBSCRIBE please visit:
>http://gameprogrammer.com/mailinglist.html
>
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
Share information about yourself, create your own public profile at
http://profiles.msn.com.
=================================================================
The GameProgrammer.Com mailing list is for the open discussion
of any topic related to the art, science, and business of
programming games. This list is especially tolerant of beginners.
We were all beginners once
To SUBSCRIBE or UNSUBSCRIBE please visit:
http://gameprogrammer.com/mailinglist.html
|
|