problem facing while using ostream_iterator

Discussion in 'C++' started by alzforu, Nov 13, 2006.

  1. alzforu

    alzforu Guest

    The code in which i m facing the problem is:

    #include <vector>
    #include <algorithm>
    #include <iostream>

    using namespace std;

    int main ()
    vector<int> V;
    string from;
    copy(V.begin(), V.end(), std::eek:stream_iterator<int>(cout, " "));
    // Output: 0 1 2
    return 0;

    // compiler given error:
    // In function `int main()': `ostream_iterator' undeclared in namespace `std' (line
    number 38 is where m calling copy() algorithm).

    I have made the search in /usr/include for ostream_iterator but i
    have'nt find it. syntax error before `>' token
    alzforu, Nov 13, 2006
    1. Advertisements

  2. alzforu

    Salt_Peter Guest

    Salt_Peter, Nov 13, 2006
    1. Advertisements

  3. alzforu

    Pete Becker Guest

    Check the documentation of ostream_iterator. It should tell you that you
    need <iterator>.


    -- Pete
    Roundhouse Consulting, Ltd. --
    Author of "The Standard C++ Library Extensions: a Tutorial and
    Reference." For more information about this book, see
    Pete Becker, Nov 13, 2006
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.