Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


#ActualAzaral

Posted 18 April 2013 - 12:18 PM

Yeah, you store a reference in a pointer.

Instead of

 

Thing &myThing = tempVector[i];

 

you want

 

Thing* myThingPointer = &tempVector[i];


A pointer stores a memory address. A reference is a memory address. This means myThingPointer will point to whatever is at the memory addres that is tempVector[i] currrently. Becareful: If the vector reconfigures itself, myThingPointer might not point to what you think it is anymore. It will still be pointing at the same address, but the contents of that address won't be the same. It could be anything.


#1Azaral

Posted 18 April 2013 - 12:17 PM

Yeah, you store a reference in a pointer.

Instead of

Thing &myThing = tempVector[i];

 

you want

Thing* myThingPointer = &tempVector[i];


A pointer stores a memory address. A reference is a memory address. This means myThingPointer will point to whatever is at tempVector[i]. Things to be careful of: If the vector gets a new heap assignment because it grew, myThingPointer might not point to what you think it is anymore.

PARTNERS