iterators

how can I pass the iterator of a list to a method of another class?
I have 3 classes that I want to connect. I have 3 lists ,one for every class. I want to do sth to one of them by having a result from one of the others. how can I have access to lists?
compiler says: iterator does not name a type
compiler says: iterator does not name a type

Each container has their own iterator type. If you have a list of integers (std::list<int>), then the iterator type will be std::list<int>::iterator.
1
2
3
4
5
6
7
8
template <typename T>
void func(std::list<T>::iterator begin, std::list<T>::iterator end)
{
    for(; begin != end; ++begin)
    {
        // stuff
    }
}
Last edited on
Out of interest, what kind of problem are you trying to sove with this approach?

Returning iterators is exposing part of the internal implementation detail of a class so should be avoided if possible.

Andy
Topic archived. No new replies allowed.