I am learning to use stl vector and It is odd that this program cannot work. What is wrong with it? How should I do if I want to implement the same function with vector?
#include <vector>
#include <iostream>
using namespace std;
int main()
{
    vector<int> vec;
    vector<int>::iterator it;
    vector<int>::iterator temp;
    it = vec.begin();
    vec.insert(it, -1);
    it++;
    vec.insert(it, 2);
    for(temp = vec.begin();temp!=vec.end();temp++)
        cout<<*temp<<' ';
    return 0;
}
 
     
    