what is best used in a loop

What is best used to regularly add and remove integers, such as array, vector, list or other? but it also has to be able to do things such as for eg. vector.size()>4 do so..... need help
Last edited on
It depends on what you are doing. If you know how many times you want to loop ahead of time you will generally use a for loop. If you don't know how many times you are going to loop ahead of time and you don't want to execute at least once use a while loop. If you aren't sure how many times you want to loop but you want to loop at least once use a do-while loop.
sorry i may of been understanding, i mean i want to know what is best used to add and remove integers from a information storer, for eg a list, a vector or a array?
it depends on where you are removing/adding. There is push_back and pop_back for adding/removing last element. There is also insert and erase for inserting and erasing arbitrary elements.
Topic archived. No new replies allowed.