On Tue, 26 Jan 1999, Fenglou Mao wrote:

> Perhaps you want to tell me to remmember the index of vector element can 
> trace them, but vector is a sequence, you can erase any element, after 
> that, the indexes you remmembered can not access the correct object.
> 
> And sometimes, pointer is the fastest way to go to another object, 
> especially in CPU-comsuming program, keep a pointer to another object is 
> very important.

If you want to maintain the pointer, I'd suggust you to store
pointers in vector.  One problem for this technique is you'll
have to call operator delete explicitly when you remove elements
from vector.  Using smart pointers (See Effective C++/More Effective C++
by Scott Meyers) solve the above problem.

Think of vector as a smart version of array that
can perform expand, insert, erase for you without having to write
everything yourself.  

Kriang

Reply via email to