[prog] Definining an array in Visual C++

Laurel Fan laurel at sdf.lonestar.org
Wed Mar 26 03:58:56 EST 2003


On Tue, Mar 25, 2003 at 06:36:11PM -0500, Terri Oda wrote:
> I've been debating whether I want to make it a vector, since I'm reasonably
> familiar with the vector class, if not the rest of the standard template
> library (It's on the list of things to learn all the time, but my past few
> jobs have been using lightweight libraries or other languages.)  But isn't a
> vector somewhat overkill, since I know the size at allocation-time and it
> doesn't change, even if I don't know it at compile time?  Would a list be
> better?

vector is probably more lightweight than list.  Which one is better
depends mostly on how you want to access the elements.  If you never
want to change it, vector is probably better, since list needs to have
extra stuff so you can delete an element in the middle of a list.  If
you're really concerned about performance, you should just new the
array.  It might even be faster than the way you're doing it now.



More information about the Programming mailing list