Solved

pointer to stl Iterators ???

Posted on 2003-12-04
2
675 Views
Last Modified: 2013-12-14
Hi guys...
I wonder if there is possible to create a list of iterator pointers...
like this...

let's say i have a class called Object, and a list och Objects.
list<Object> objectList;

now if I search that list of objects with a iterator and find a object that I would like to "remeber" the position of...now, is there a possibility to have a pointer
that can point to these kind of iterators ?
or maybe even have another list of pointers to different iterator positions?

using std :: list<Object> :: iterator;
list<Iterator> iteratorList;  // ???

well I dont have any compilers yet so I cant test it :/
0
Comment
Question by:shdr
2 Comments
 
LVL 8

Accepted Solution

by:
mnashadka earned 125 total points
ID: 9877059
The iterator itself is kind of like a pointer, so you wouldn't need to create a list of pointers to iterators, only iterators.  It might look something like:
typedef std::list<Object>::iterator Iterator; // This just makes the next line a little cleaner
std::list<Iterator> iterators; // Create the list of iterators
// Add some iterators to the list
iterators.push_back(my_iterator);

// Then you can go through that list
for(std::list<Iterator>::iterator iter = iterators.begin(); iter != iterators.end(); ++iter)
{
  if((*iter)->x == 12) // You'll have to dereference the iterator to use it
  {
    do_something();
  }
}
0
 

Author Comment

by:shdr
ID: 9877253
thanks for the quick and helpful answer mnashadka, it worked :D
0

Featured Post

ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question