   Is it ok to dereference like so....    
  Yeah, I got class....class CSprite{   vector < CTexture * > Frames;}then we do something nasty in code to get a refernce....CTexture * Frame = &(*Frames[frameNum]);Is this proper? I typically stay away from the STL but, times change....From what it looks like though, using a vector of pointers may be a problem no? Won't these suckers get shifted around when I push and pop members?  Ergo, how do we keep track of the pointers.... I suppose that makes two questions.    "Five passengers set sail that day, for a three hour tour, a three hour tour...."[edited by - Joviex on April 2, 2003 6:02:41 AM]
quote:Original post by Joviexthen we do something nasty in code to get a refernce....CTexture * Frame = &(*Frames[frameNum]);  I assume that your vector looks like this:vector<CTexture*> Frames; If so, writingCTexture *Frame = &(*Frames[frameNum]);is the same asCTexture *Frame = Frames[frameNum];The operator[] returns a value stored in the vector, which, in your case, is a pointer (not a reference).quote:Won't these suckers get shifted around when I push and pop members? Ergo, how do we keep track of the pointers  The order will not change by adding or removing in some uncontrolled manner. If you remove some element, the preceding elements will be shifted by -1 and a push will result in that the preceding elements will be shifted +1. Think of a vector as a dynamic array.Regards MatsEdits: '<' and '&qt' + spelling + < and > again...  [edited by - Matsen on April 2, 2003 6:03:12 AM][edited by - Matsen on April 2, 2003 6:11:02 AM][edited by - Matsen on April 2, 2003 6:14:20 AM];  If you need to push and pop a lot don't use vector, use list (or possibly stack).It's no problem using pointers in a stl container. Just usevector<type*>    instead ofvector<type>    You can use subscript to access elements in a vector, or iterators. Iterators are more generic and work on ANY stl-container. So they're the preferred way of stepping through your container.[edited by - Jedyte on April 2, 2003 6:02:19 AM]