🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: att.lang.c++
Article #167

How to get an element from a stl map

#167
From: Wim Hoogstad
Date: Sun, 28 Mar 1999 00:00
32 lines
1028 bytes
Does enyone know how to get an element from a map
When you use STL

I have the following C++ code.


typedef  map< int, int*, less < int > >  TMyMap;

int *n = NULL;
TMyMap MyMap;
// struct pair<int,int *> n;

int function() {
 TMyMap::iterator i;

 for ( i = MyMap.begin();
  i != MyMap.end() ;
  ++i) {
  n = *i;

 }
 return 0;
}

It produces the following error:
error C2679:
  binary '=' : no operator defined which takes a right-hand operand of
     type 'struct pair<int,int *>' (or there is no acceptable conversion)


In the row with "n = *i;"
Can anyone give mi a hind.
Technical Details
Message-ID: <7dm1it$eps$1@news.Kijfhoek.NL.net>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10d4ba,70bce12e77639e4a,start
X-Google-Attributes: gid10d4ba,public
From: "Wim Hoogstad" <W.G.Hoogstad@inter.nl.net>
Subject: How to get an element from a stl map
Date: 1999/03/28
Message-ID: <7dm1it$eps$1@news.Kijfhoek.NL.net>
X-Deja-AN: 460096626
Organization: NLnet
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3
Newsgroups: att.lang.c++