Beginner C ++ vector container

Finally, add a data array in 1.push_back

2.pop_back remove the last data array

3.at obtain position data number

4.begin head pointer array give

5.end obtain a pointer to the last cell array of +1

 

#include<string.h>
#include<vector>
#include<iostream>
#include<algorithm>
using namespace std;

int main ()
{
    // sequential access 
    Vector < int > HH;
     for ( int I = 0 ; I < 10 ; I ++ )
    {
        hh.push_back (I); // vector tail additive element I 
    }
    cout<<"用数组:";
    for(int i =0;i<10;i++)
    {
        cout<<hh[i]<<" ";
    }
    
    cout << endl; // End 
    cout << " with iterators: " ;
    the Vector < int > :: Iterator IT; // declare iterator 
    for (IT = hh.begin ();! IT = hh.end (); IT ++ )
    {
        cout<<*it<<" ";
        
    }
    return 0; 
}

Guess you like

Origin www.cnblogs.com/claudia529/p/12034275.html