copy(..., ostream_iterator<int>(cout, " ")) cannot compile, why?

Discussion in 'C++' started by Scofield, Aug 20, 2007.

  1. Scofield

    Scofield Guest

    copy (coll.begin(), coll.end(), ostream_iterator<int>(cout, " "));

    when compile, it yields the following errors:
    list1.cpp:12: error: ¡®ostream_iterator¡¯ was not declared in this scope
    list1.cpp:12: error: expected primary-expression before ¡®int¡¯

    I have included header file iostream and
    using namespace std;

    will you please explain why? any solutions?
     
    Scofield, Aug 20, 2007
    #1
    1. Advertising

  2. On Aug 20, 2:23 pm, Scofield <> wrote:
    > copy (coll.begin(), coll.end(), ostream_iterator<int>(cout, " "));
    >
    > when compile, it yields the following errors:
    > list1.cpp:12: error: 'ostream_iterator' was not declared in this scope
    > list1.cpp:12: error: expected primary-expression before 'int'
    >
    > I have included header file iostream and
    > using namespace std;
    >
    > will you please explain why? any solutions?


    #include<iterator>

    -N
     
    Neelesh Bodas, Aug 20, 2007
    #2
    1. Advertising

  3. Scofield

    Scofield Guest

    Neelesh Bodas дµÀ:
    > On Aug 20, 2:23 pm, Scofield <> wrote:
    >> copy (coll.begin(), coll.end(), ostream_iterator<int>(cout, " "));
    >>
    >> when compile, it yields the following errors:
    >> list1.cpp:12: error: 'ostream_iterator' was not declared in this scope
    >> list1.cpp:12: error: expected primary-expression before 'int'
    >>
    >> I have included header file iostream and
    >> using namespace std;
    >>
    >> will you please explain why? any solutions?

    >
    > #include<iterator>
    >
    > -N
    >

    oh, sorry, i made a silly mistake.
     
    Scofield, Aug 20, 2007
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Schnoffos
    Replies:
    2
    Views:
    1,237
    Martien Verbruggen
    Jun 27, 2003
  2. Hal Styli
    Replies:
    14
    Views:
    1,686
    Old Wolf
    Jan 20, 2004
  3. Mr. SweatyFinger
    Replies:
    2
    Views:
    2,090
    Smokey Grindel
    Dec 2, 2006
  4. , India
    Replies:
    3
    Views:
    4,230
    James Kanze
    Oct 1, 2007
  5. powerhouse04
    Replies:
    1
    Views:
    325
    powerhouse04
    Dec 16, 2007
Loading...

Share This Page