C++ 流迭代器

输出流迭代器

#include
#include
#include
#include

using namespace std;

int main()
{
    int sz[6] = { 1, 2, 3, 4, 5, 6 };
    vector ob(sz, sz + 6);
    ostream_iteratorosi(cout, " ");
    copy(ob.begin(), ob.end(), osi);
    cout << endl;
    return 0;

}

输入流迭代器

#include
#include
#include
#include

using namespace std;

int main()
{
    vectorob;
    istream_iteratorisi(cin);
    copy(isi, istream_iterator(), back_inserter(ob));
    for (vector::iterator it = ob.begin(); it != ob.end(); it++)
    {
        cout << (*it) << " ";
    }
    cout << endl;
    return 0;
}

你可能感兴趣的:(C++ 流迭代器)