std::string operator == error! help!

muddogxp 2003-12-11 04:57:53
typedef std::vector<std::string> sTable;
sTable id_table;
.........
...........
sTable::iterator vi = id_table.begin();
bool intable = false;
int index = 0;

std::string tempstring = temp_string;

if(vi)
do{
if(*vi == tempstring){ // error!!
intable = true;
break;
}
index++;
}while(++vi);


error C2784: 'bool __cdecl std::operator ==(const class std::multimap<_K,_Ty,_
Pr,_A> &,const class std::multimap<_K,_Ty,_Pr,_A> &)' : could not deduce templ
ate argument for 'const class std::mu
ltimap<_K,_Ty,_Pr,_A> &' from 'class std::basic_string<char,struct std::char_t
raits<char>,class std::allocator<char> >'

可string 的opeartor == STL中重载过了啊,
怎么会类型不匹配啊??
ft

ps:VC6。0下编译!

...全文
65 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
heguobaoceo 2003-12-11
  • 打赏
  • 举报
回复

应该是你少定义了一个参数
在定义VECTOR模板时它声明了multimap类
你应该定义bool operator==(const class ID & x,const ID & y)声明*vi==tempstring

类型不匹配
去看C++库声明和你的VC++中INCLUDE中的<VECTOR.H>文件
danielhf 2003-12-11
  • 打赏
  • 举报
回复
1, 迭代器不能用指针的判断方法 if ( vi ) => if ( vi!= id_table.end() )
2, tempstring 没有声明 //代码不全
chelsea 2003-12-11
  • 打赏
  • 举报
回复
代码贴的不全吧?

此vi的类型还是vector<string>::iterator?
编译错误怎么是map的operator == ?

24,856

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 工具平台和程序库
社区管理员
  • 工具平台和程序库社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧