|
-
Sep 20th, 2001, 11:12 AM
#7
Monday Morning Lunatic
The vector is initialised, and it's empty. You add one more item to it using push_back. It then allocates enough space for 5 items (may be some other value, I think you can choose in the constructor or template arguments), and sets the reserved size to 5. However, the USED size is only 1.
It copies your data into the first element in the buffer.
When you come to add another element, it knows it has space so it merely adds them to the memory it already has. If it runs out (already got 5 items) then it allocates more memory (with the excess of 5) and copies the data in, appending the new item.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|