I need help trying to compile and test this code, but I keep getting the error: template is incomplete, can not parse field.

Here is my code:

using namespace std;
template <class T>
class my_istream_iterator
        typedef charT char_type;
        typedef traitsT traits_type;
        typedef basic_istream<charT, traitsT> istream_type;
        typedef input_iterator_tag iterator_category;
        typedef T        value_type;
        typedef diff        difference_type;
        typedef const T*    pointer;
        typedef const T&    reference;

        my_istream_iterator():is(0), pred(false) {}
        my_istream_iterator( istream_type &s ):is(&s) { read_next();}
        reference operator*() const
            return current;
        pointer operator->() const
            return &(operator*());
        my_istream_iterator& operator++()
            return *this;

        my_istream_iterator operator++(int)
            my_istream_iterator temp = *this;
            return temp;

        bool my_equal(const my_istream_iterator &x) const
            return (pred == x.pred) && (!pred || is == x.is);

        T current;
        istream_type *is;
        bool pred;
        void read_next()
            if( is == NULL || (is >> current))
                is = NULL;

template<class T>
bool operator==(const my_istream_iterator<T> &is1, const my_istream_iterator<T> &is2)
    return is1.my_equal(is2);

template<class T>
bool operator!=(const my_istream_iterator<T> &is1, const my_istream_iterator<T> &is2)
    return !is.my_equal(is2);

    vector<int> v;
    my_istream_iterator<vector<int> > is(cin);
    my_istream_iterator<vector<int> > eof;
    copy(is, eof, back_inserter(v));
    copy(v.begin(), v.end(), ostream_iterator<int>(cout, "\t"));
    cout << endl;

can someone tell me what I'm doing wrong and how do I make the template complete?

Thank You,

Your types are all screwed up. You use charT, traitsT, and diff without defining them, for instance.

This article has been dead for over six months. Start a new discussion instead.