c++ iterator skype chat!

Hello,can anyone explain me about iterator? I know a little bit about it, but wouldn't be able to create something serious ! :]




Also skype chat :
Begginners of C++ skype chat! 6People atm ,creating it tommorow ,add me in skype (mantasxxl3) if you want to join us :P . [So we can help each other ,without spamming forums and waiting hours for an answer :) ]
try this

1
2
3
4
5
6
7
8
9
    std::vector< unsigned int > vec;
    std::vector< unsigned int >::iterator it;
    vec.push_back( 1 );
    vec.push_back( 4 );
    vec.push_back( 8 );
    for( it = vec.begin(); it != vec.end(); it++ )
    {
        std::cout << *it << "  " << std::flush;
    }
closed account (zb0S216C)
An iterator is a concept which is designed to transverse, and possibly modify, the elements of a container, though, the concept of iterators is not reserved specifically for containers. There are three main types of iterators:

1) Bi-directional iterators: these iterators can move freely between the first and last element of a container.

2) Forward iterators: these iterators can only transverse a container from the first element to the last and no higher. C++ containers contain a "begin( )" member-function which returns an iterator to the very first element of the container.

3) Reverse iterators: these iterators can only transverse a container from the end element to the first element and no lower. C++ containers contain a "rbegin( )" member-function which returns the last element of the container.

There are also "constant iterators" which behave in the same way as non-constant iterators, but as the name implies, they cannot modify the elements of a container.

Standard C++ containers contain the following iterators:

"Container::iterator": non-constant bi-directional iterator
"Container::const_iterator": constant bi-directional iterator
"Container::reverse_iterator": non-constant reverse iterator
"Container::const_reverse_iterator": constant reverse iterator

Note the absence of forward iterators. This is because in C++, containers use the bi-directional iterator to represent the forward iterators as well as the reverse iterator.

Wazzak
Last edited on
Topic archived. No new replies allowed.