Should I use an array in a class?

Started by
11 comments, last by ace_muncher 22 years, 6 months ago
vector''s are very good .
the grow exponentially though.

1 tip is to reserve your vector before using it.
Common mistake is inserting elements into a vector
without reserving it yourself..

         myvec.reserve(25); // reserve 25 blocks   


this speeds up your vector ..

{ Stating the obvious never helped any situation !! }
Advertisement
If you know how many elements ahead of time you want in the array, then use the ARRAY!!!!!!!!!!!!!!!!!!

The only time vectors are really needed are when you dont know how many elements/want to create more dynamically.

-nt20
hmmmm
not exactly .

if you are reading records from a file, you can calculate
how many records are in the file.

but then the number of records in memory can grow.
so use a vector if you can .



{ Stating the obvious never helped any situation !! }

This topic is closed to new replies.

Advertisement