Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > second parameter to istream_iterator class template

Thread Tools

second parameter to istream_iterator class template, India
Posts: n/a

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.


Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Declaring a template class with two template params a friend in anon-template class A L C++ 1 08-25-2010 07:25 AM
Using declaration inside first template parameter as default valuefor second template parameter. Stuart Redmann C++ 5 12-14-2007 08:42 AM
template class instantiate without template parameter, automatic type deduction Fei Liu C++ 4 10-26-2007 02:39 PM
template class instantiate without template parameter, automatictype deduction Fei Liu C++ 0 10-25-2007 08:12 PM
A parameterized class (i.e. template class / class template) is not a class? christopher diggins C++ 16 05-04-2005 12:26 AM