Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

stl multimap

Status
Not open for further replies.

RubyNet

Programmer
Mar 27, 2003
1
US
Hi Experts,

i want to delcare a multimap int -> char*
is it possible ?
currently i declare it like this
typedef std::multimap< int, string , std::less< int > > mmid;
mmid collocs1;

i get an error:
c:\documents and settings\user\my documents\courses\textmining\tdm\tdm-0.0.1\vcpp\flexfeatureextraction\freqtest.cpp(68) : error C2039: 'value_types' : is not a member of 'multimap<int,class std::basic_string<char,struct std::char_traits<char>,class

at the line:
collocs1.insert( mmid::value_types( 30, &quot;hello&quot;));

what could be possibly be wrong with the declaration or i have to enclose the char*
in a class and then insert it ??


Thanks in advance.

Ruby
 
std::multimaps and std::maps contain pairs, not individual elements.

The following should work for you...

Code:
multimap<int, string, less<int> > mmid;
string temp = &quot;hello&quot;;
mmid.insert(make_pair(30, temp));
 
That's true.

However, mmid::value_type is an std::pair. So the original post was correct, there was just a typo (value_type, not value_types).
 
No problems. Your answer was perfectly right; I was just pointing out some extra info.
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Sponsor

Back
Top