Solved

pointer to stl Iterators ???

Posted on 2003-12-04
2
698 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 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
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.

690 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