Re: no match for complain

From: SaltPeter (SaltPeter_at_Jupiter.sys)
Date: 06/29/04


Date: Tue, 29 Jun 2004 03:19:35 -0400


"Edo" <edwardoJE@aking.com> wrote in message
news:40e0b7fc@dnews.tpgi.com.au...
> Hello
> what is the problem. I declared every thing "I think" right, why it is
> complaining
> Untitled1.cpp:16: no match for `std::_List_iterator<double, double&,
> double*>& < std::_List_iterator<double, double&, double*>' operator

Its not complaining, its telling you that no operator > is defined for an
iterator. And thats a good thing once you start to understand iterators,
including reverse iterators. Iterators are not meant to be compared with
each other.

Why aren't you reading up on how to initialize and step through a sequence
of iterators? The same goes for the universal push and pop STL container
member functions? Since these are common in that most containers (with the
appropriate exceptions) rely on a consistent function naming convention.

examples:

std::vector<int> vn;
vn.push_back(99);

std::deque<int> dn;
dn.push_back(99);

std::list<int> ln;
ln.push_back(99);

and the same can be said for their iterators (albeit there are various types
of iterators).

>
> thanks
>
> #include <iostream>
> using std::cout;
> using std::endl;
>
> #include <list>
> using std::list;
>
>
> int main()
> {
> list<double>::iterator it;
> list<double> lst;
> *it = 34;

Why are you using an undefined iterator?

Declare the empty list, "push_back()" onto it, then set the iterator to a
given end. Then iterate through the sequence in std::list container. Its
exactly the same procedure for a vector, list, queue, etc...

If you want to provide an index number during output, then code one in.

<snip>

#include <iostream>
#include <list>

int main()
{
    std::list<double> dlist;
    std::list<double>::iterator iter;

    dlist.push_back(34.0);
    dlist.push_back(45.0);
    dlist.push_back(87.0);

    int index = 1;
    for (iter = dlist.begin(); iter != dlist.end(); ++iter)
    {
        std::cout << index++ << '\t' << *iter << std::endl;
    }

    return 0;
}