能不能介绍介绍它的功能和用法。

解决方案 »

  1.   

    push_back 
    []
    find
    sort
    ....
      

  2.   

    #pragma warning(disable:4786)#include <iostream>
    #include <vector>using namespace std ;typedef vector<int> INTVECTOR;const ARRAY_SIZE = 10;void ShowVector(INTVECTOR &theVector);int main()
    {
        // Dynamically allocated vector begins with 0 elements.
        INTVECTOR theVector;    // Intialize the vector to contain the numbers 0-9.
        for (int cEachItem = 0; cEachItem < ARRAY_SIZE; cEachItem++)
            theVector.push_back(cEachItem);    // Output the contents of the dynamic vector of integers.
        ShowVector(theVector);    // Using void iterator erase(iterator Iterator) to
        // delete the 6th element (Index starts with 0).
        theVector.erase(theVector.begin() + 5);    // Output the contents of the dynamic vector of integers.
        ShowVector(theVector);    // Using iterator erase(iterator First, iterator Last) to
        // delete a range of elements all at once.
        theVector.erase(theVector.begin(), theVector.end());    // Show what's left (actually, nothing).
        ShowVector(theVector);
    }// Output the contents of the dynamic vector or display a
    // message if the vector is empty.
    void ShowVector(INTVECTOR &theVector)
    {
        // First see if there's anything in the vector. Quit if so.
        if (theVector.empty())
        {
            cout << "theVector is empty." << endl;
            return;
        }    // Iterator is used to loop through the vector.
        INTVECTOR::iterator theIterator;    // Output contents of theVector.
        cout << "theVector [ " ;
        for (theIterator = theVector.begin(); theIterator != theVector.end();
             theIterator++)
        {
            cout << *theIterator;
            if (theIterator != theVector.end()-1) cout << ", ";
                                                  // cosmetics for the output
        }
        cout << " ]" << endl ;
    }
    Output
    theVector [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ]
    theVector [ 0, 1, 2, 3, 4, 6, 7, 8, 9 ]
    theVector is empty.
      

  3.   

    For more detail infomation please refer:
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcstdlib/html/vclrfvectormembers.asp