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;
}



Relevant Pages

  • Re: Under what circumstances can the STL move a vector?
    ... > vector in the first element on the heap is moved, thus invalidating ... Each container has well defined semantics on how and when iterators ... and references into the container become invalidated. ...
    (comp.lang.cpp)
  • Re: Interface of the set classes
    ... > container usually depend on the data set. ... > templates, iterators, probably tags, and on. ... Python has iterators, and doesn't need templates, since signature based ... The equivalent of "specializing a template" ...
    (comp.lang.python)
  • Re: Reinventing the iterator
    ... this environmental benefit from iterators. ... the container once from beginning to end. ... iterator-based algorithms are good for any ... (defmethod find (item (container array)) ...
    (comp.lang.lisp)
  • Re: Seed7 Release 2007-05-07
    ... You do not need iterators ... I am sure it is possible to declare ... Iterators in Seed7. ... I meant different container types. ...
    (comp.lang.misc)
  • Re: STL algorithms with vectors of c++ objects
    ... however you are asking equal_range to compare one of these to an int. ... If socket_node_live is a private member, which it probably ought to be, ... That ought to work assuming the rest of your code is OK. ... > what i'm trying to do is to get the pair of iterators ...
    (microsoft.public.vc.stl)