使用multimap时出现的问题,请赐教!
wxb 2002-05-15 12:36:07 小弟正在尝试使用STL,写了一小段程序试试multimap,出了一些不太理解的error,请帮忙看看哪里不对,多谢了!
程序如下:
typedef struct pair<string, int> BAD_SPEECH_INDEX;
typedef struct pair<int, string> BAD_SPEECH_INFO;
int faint = 1;
char s_fuck[] = {"rerqwrewqr"};
char* sp = s_fuck;
string string_test = string(sp);
pair<string, int> si_pair = make_pair(string(sp), faint);
pair<int, string> si_pair1 = make_pair(++faint, string(sp));
pair< BAD_SPEECH_INDEX, BAD_SPEECH_INFO > pair1 = make_pair(si_pair, si_pair1);
multimap< BAD_SPEECH_INDEX, BAD_SPEECH_INFO > bad_sent;
bad_sent.insert(pair1);
出现了12个errors, 30个warnings,warning主要是4786,由于warning太长了,就不列在这里了。
★error如下:
c:\program files\microsoft visual studio\vc98\include\utility(39) : error C
2784: 'bool __cdecl std::operator <(const class std::multimap<_K,_Ty,_Pr,_A>
&,const class std::multimap<_K,_Ty,_Pr,_A> &)' : could not deduce template
argument for 'const cl
ass std::multimap<_K,_Ty,_Pr,_A> &' from 'const class std::basic_string<char
,struct std::char_traits<char>,class std::allocator<char> >'
c:\program files\microsoft visual studio\vc98\include\functional(86)
: see reference to function template instantiation 'bool __cdecl std::opera
tor <(const struct std::pair<class std::basic_string<char,struct std::char_t
raits<char>,class std
::allocator<char> >,int> &,const struct std::pair<class std::basic_string<ch
ar,struct std::char_traits<char>,class std::allocator<char> >,int> &)' being
compiled
c:\program files\microsoft visual studio\vc98\include\utility(39) : error C2
784: 'bool __cdecl std::operator <(const class std::map<_K,_Ty,_Pr,_A> &,con
st class std::map<_K,_Ty,_Pr,_A> &)' : could not deduce template argument fo
r 'const class std::m
ap<_K,_Ty,_Pr,_A> &' from 'const class std::basic_string<char,struct std::ch
ar_traits<char>,class std::allocator<char> >'
c:\program files\microsoft visual studio\vc98\include\functional(86)
: see reference to function template instantiation 'bool __cdecl std::opera
tor <(const struct std::pair<class std::basic_string<char,struct std::char_t
raits<char>,class std
::allocator<char> >,int> &,const struct std::pair<class std::basic_string<ch
ar,struct std::char_traits<char>,class std::allocator<char> >,int> &)' being
compiled
c:\program files\microsoft visual studio\vc98\include\utility(39) : error C2
784: 'bool __cdecl std::operator <(const class std::_Tree<_K,_Ty,_Kfn,_Pr,_A
> &,const class std::_Tree<_K,_Ty,_Kfn,_Pr,_A> &)' : could not deduce templa
te argument for 'cons
t class std::_Tree<_K,_Ty,_Kfn,_Pr,_A> &' from 'const class std::basic_strin
g<char,struct std::char_traits<char>,class std::allocator<char> >'
c:\program files\microsoft visual studio\vc98\include\functional(86)
: see reference to function template instantiation 'bool __cdecl std::opera
tor <(const struct std::pair<class std::basic_string<char,struct std::char_t
raits<char>,class std
::allocator<char> >,int> &,const struct std::pair<class std::basic_string<ch
ar,struct std::char_traits<char>,class std::allocator<char> >,int> &)' being
compiled
.....................................
Error executing cl.exe.
misc.exe - 12 error(s), 30 warning(s)
还请大侠指教。谢谢!