second parameter to istream_iterator class template

Discussion in 'C++' started by subramanian100in@yahoo.com, India, May 11, 2010.

  1. , India

    , India Guest

    Consider:

    template <typename T,
    typename charT = char,
    typename traits = char_traits<charT>,
    typename Difference = ptrdiff_t>
    class istream_iterator;

    I pass only the element type like 'int' as in
    istream_iterator<int> isi(cin);

    In the above construction, the second parameter to the class template
    istream_iterator is the default argument 'char' which is taken by
    default because I did not supply the second argument.

    What other types can we specify as the second argument to the second
    parameter ? What is the significance of this second parameter and
    where is it useful to provide a programmer-supplied second
    argument(kindly provide a code sample for this) ?

    Suppose 'Test' is a user-defined class type. Can we write like:
    istream_iterator<int, Test> isi(cin);
    What is its meaning of passing the second argument which is different
    from the default 'char' ?

    Kindly explain.

    Thanks
    V.Subramanian
     
    , India, May 11, 2010
    #1
    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. christopher diggins
    Replies:
    16
    Views:
    773
    Pete Becker
    May 4, 2005
  2. Fei Liu
    Replies:
    0
    Views:
    435
    Fei Liu
    Oct 25, 2007
  3. Stuart Redmann
    Replies:
    5
    Views:
    505
    Stuart Redmann
    Dec 14, 2007
  4. A L
    Replies:
    1
    Views:
    523
    Alf P. Steinbach /Usenet
    Aug 25, 2010
  5. yelipolok
    Replies:
    4
    Views:
    279
    John W. Krahn
    Jan 27, 2010
Loading...

Share This Page