AW: STL - How to use iterators?

Ivan Martinez ex08@kalman.iau.dtu.dk
Tue Feb 15 02:36:00 GMT 2000


May Adrian wrote:
> class A
> {
>     public:
>         ...
>         int number;
            
A(int n):number(n){}
> }
>
>
> main (int argc, char *argv []) {
>     list<A> l;
>     A a1(10), a2(20), a3(30);
>     l.push_back (a1);
>     l.push_back (a2);
>     l.push_back (a3);
>
       //notice !=, not < ...
       for (list<A>::iterator i =
l.begin();i != l.end() ; i++)
               
cout << (*i).number << endl;
        }
On the one hand "i" is a "list<A>::iterator". Ont the other docs tell
about "iterator_traits", "input_iterator_tag", "bidirectional_iterator"...
What type is "iterator"?
-- 
Ivan Martinez (Rodriguez)
Bch in Computer Science - MSc student
http://www.student.dtu.dk/~u990873
"Ponia Windows98 o superior, asi que instale Linux"
 



More information about the Gcc-help mailing list