delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/01/26/06:32:55

From: "Niklas Pettersson" <npedt97 AT student DOT vxu DOT se>
Newsgroups: comp.os.msdos.djgpp
Subject: How should I use the Iterator with a map???
Date: Wed, 26 Jan 2000 10:33:13 +0100
Organization: Lund Institute of Technology, Sweden
Lines: 41
Message-ID: <86mf46$4ua$1@news.lth.se>
NNTP-Posting-Host: npedt97.univ.vxu.se
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.2314.1300
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

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?

Thanks in advance / Niklas Pettersson

#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++;
   }
}





- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019