delorie.com/archives/browse.cgi | search |
From: | Damian Yerrick <MYNAMEISd_yerrick AT hotmail DOT comNO2CANNEDHAM> |
Newsgroups: | comp.os.msdos.djgpp,comp.lang.c++ |
Subject: | Re: How should I use the Iterator with a map??? |
Organization: | Pin Eight Software http://pineight.8m.com/ |
Message-ID: | <5m4u8s87c42f2s9mldsrr7rgf6iaasu9fr@4ax.com> |
References: | <86mf46$4ua$1 AT news DOT lth DOT se> |
X-Newsreader: | Forte Agent 1.7/32.534 |
MIME-Version: | 1.0 |
Lines: | 49 |
X-Trace: | +rTuhoF++YTifXafR3HsqlZhuZQaNMjmX0yqnLc5zUxPpLbJEW/5TFU69pYmdHQiWI1qznkcz+Bx!awcFpbyqU2wX1fuQU4gWVmKOre/eGKfAxybAoutyamRcEajK5HEyjxOKuQFmk4QR2eqQmEczeg== |
X-Complaints-To: | abuse AT gte DOT net |
X-Abuse-Info: | Please be sure to forward a copy of ALL headers |
X-Abuse-Info: | Otherwise we will be unable to process your complaint properly |
NNTP-Posting-Date: | Wed, 26 Jan 2000 15:31:49 GMT |
Distribution: | world |
Date: | Wed, 26 Jan 2000 15:31:49 GMT |
To: | djgpp AT delorie DOT com |
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
Reply-To: | djgpp AT delorie DOT com |
On Wed, 26 Jan 2000 10:33:13 +0100, "Niklas Pettersson" <npedt97 AT student DOT vxu DOT se> wrote: >Hello! > >I have been programming C++ for quite some time but I havn't used the >standard containers very much.. Right now I'm building a compiler and I have >a problem with using iterators on a map... This code shows my point (and >generates an error with DJGPP)... What is wrong with this code? Shouldn't I >be able to use the * operator to get the contents of the iterator? You might get more help in comp.lang.c++. Crosspost added. >#include <string> >#include <map> > >struct SymbolTableEntry // Dummy.. Just to illustrate.. >{ >}; > >map<string, SymbolTableEntry *> symboltable_rep; > >void print() >{ > map<string, SymbolTableEntry *>::iterator i( symboltable_rep.begin() ); > SymbolTableEntry *current = 0; > > while ( i != symboltable_rep.end() ) // end is one past last element > { > // > // ERROR HERE!!! > // > current = *i; // Get contents of iterator... > > // Do stuff here with current > > i++; > } >} > > > > -- Damian Yerrick http://yerricde.tripod.com/ View full sig at http://www.rose-hulman.edu/~yerricde/sig.html Comment on story ideas at http://home1.gte.net/frodo/quickjot.html
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |