LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-10-2006, 03:26 AM   #1
YaK.
LQ Newbie
 
Registered: Nov 2005
Posts: 6

Rep: Reputation: 0
C++, getting a value from a list


Hello,

I know that with maps and vectors it's possible to get all the values saved in them with the [] operator. In lists it's not possible to get the values like this because I think a list has no random acces, but it must be possible to get all values by iterating. If I have an iterator i pointing to a position of the list how can I get the value saved at this position?

Thx for help
 
Old 01-10-2006, 03:49 AM   #2
spooon
Senior Member
 
Registered: Aug 2005
Posts: 1,755

Rep: Reputation: 51
Use * to dereference an iterator: *iter

for example:
Code:
list<string> foo;
for (list<string>::iterator iter = foo.begin(); iter != foo.end(); iter++) {
  cout << *iter << endl;
}
in the above example *iter is a string
 
Old 01-10-2006, 04:01 AM   #3
YaK.
LQ Newbie
 
Registered: Nov 2005
Posts: 6

Original Poster
Rep: Reputation: 0
ah, thanks a lot
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Need Recommendation for Debian Etch sources.list ( /etc/apt/sources.list ) forgox Debian 6 05-05-2007 01:57 PM
XFCE - window list on panel, or panel objects on window list? nagromo Linux - Software 3 01-29-2005 09:19 PM
get list of latest list of packages bobwall Linux - Distributions 1 11-30-2004 03:48 PM
wireless channel list different from router's list heluani Linux - Laptop and Netbook 1 08-29-2004 10:04 PM
Inserting element to a list of list in C suwandy_chandra Programming 2 03-09-2004 03:08 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:19 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration