1. ## Using Vectors

I am currently working on vectors and I understand them but I would understand them better if I knew where in a program they would be used.

2. Anywhere you'd normally use an array.

3. Especially if you don't know how much space you'll need.

4. and also if you don't know the size of a data container...

example
Code:
```#include <iostream>
#include <vector>     // a must for vector use
using namespace std;

int main()
{
vector<int> iVector;   // you have to specify the vector type by a class or a structure
int temp;

cout<<"How many numbers do you want to enter? ";

for(int i=0; i < answer; i++)
{
cout<<answer<<" Enter a number: ";     // display how many numbers the user has left to enter
cin>>temp;
iVector.push_back(temp);
// this is magic... the temporary integer is pushed onto the back of the vector...and given a location in that vector, which you can access using iVector[anumber]
}
return0;
}```
i prefer using vectors over arrays any day...
Only thing I hate doin, though, is that to access an object of a vector class (ex. iVector.erase()) you have to create a vector iterator that points to a location in the vector

ex.
Code:
```class aClass
{
public:
int number;
}

aClass theClass;
vector<aClass> theClassV;
vector<aClass>::iterator theClassVIterator;

for(int i=0;i<=3;i++)
{
theClass[i].number=i;
theClassV.push_back(theClass);
}

//                                                          0             1               2
// so now theClassV vector holds {theClass, theClass, theClass}
// at the storage spaces 0, 1, 2
// If i wanted to delete what was at location 1 I would have to do this...

for(i=0;i<=2;i++)
{
theClassVIterator++;
}

theClassV.erase(theClassVIterator);```
this is the only way ive found how to make the iterator the position of the vector you want...there probably is a pro somewhere around here who can be sure...

5. Um, gL_nEwB, despite the name, theClassVIterator is a vector<aClass>.
Assuming such an element exists, if you wanted to delete the element at 'location 1', you would use:
Code:
`theClassV.erase(theClassV.begin() + 1);`