vector Construct

#include<vector>
#include<iostream>
using namespace std;
void Test();


void main()
{
    int a[]={1,2,3,4,5};
    vector<int> v_a(a,a+5);
    vector<int> v_b(v_a.begin(),v_a.end());
    
    vector<int>::iterator it;
    for (it=v_a.begin();it!=v_a.end();++it)
    {
        cout<<*it<<" ";
    }
    cout<<endl;

    ///////////////////////
    for (it=v_b.begin();it!=v_b.end();++it)
    {
        cout<<*it<<" ";
    }
    cout<<endl;

    ///////////////////////    
    Test();
}

void Test()
{
    int a[]={1,2,3,4,5};
    vector<int> v_a(a,a+4);
    vector<int> v_b(v_a.begin(),v_a.end());
    
    vector<int>::iterator it;
    for (it=v_a.begin();it!=v_a.end();++it)
    {
        cout<<*it<<" ";
    }
    cout<<endl;

    ///////////////////////
    for (it=v_b.begin();it!=v_b.end();++it)
    {
        cout<<*it<<" ";
    }
    cout<<endl;

    ///////////////////////    
    
}

// 1 2 3 4 5
// 1 2 3 4 5
// 1 2 3 4
// 1 2 3 4
// Press any key to continue
原文地址:https://www.cnblogs.com/sky20080101/p/6399811.html