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:
    //file stream.cc

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

    using namespace std;


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

    // compiler given error:
    //stream.cc: In function `int main()':
    stream.cc:38: `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.
    stream.cc:38: syntax error before `>' token
     
    alzforu, Nov 13, 2006
    #1
    1. Advertisements

  2. alzforu

    Salt_Peter Guest

     
    Salt_Peter, Nov 13, 2006
    #2
    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. -- www.versatilecoding.com
    Author of "The Standard C++ Library Extensions: a Tutorial and
    Reference." For more information about this book, see
    www.petebecker.com/tr1book.
     
    Pete Becker, Nov 13, 2006
    #3
    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.