Mail Archives: djgpp/1998/09/19/19:16:58
From: | "Chia" <chia AT top DOT net>
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | STL Iterators
|
Date: | Sat, 19 Sep 1998 18:15:45 -0500
|
Organization: | 404 Software
|
Lines: | 28
|
Message-ID: | <6u1dp7$lu6@nnrp1.farm.idt.net>
|
NNTP-Posting-Host: | flex-2.top.net
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
I'm just starting to work with the STL and I've been working with the list
class.
I've had some problems with the iterators, though.
I'm trying to select, say, the tenth element in a list.
list<int> *foo;
for(int i = 0;i < 100;i++) foo.push_back(i);
list<int>::iterator p = foo.begin() + 10; // error
This won't compile, giving for a reason that there's no match for:
operator +(class list<int>::iterator, int)
I have had success with incrementing p ten times:
for(int i = 0;i < 10;i++) p++;
Is there a way to do this more easily or something that I'm doing wrong
here?
Thanks!
// chia AT top DOT net -- http://www.top.net/chia/
- Raw text -