?
Solved

pointer to stl Iterators ???

Posted on 2003-12-04
2
Medium Priority
?
703 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 8

Accepted Solution

by:
mnashadka earned 500 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
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 pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
Suggested Courses
Course of the Month15 days, 14 hours left to enroll

743 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