请教关于重载的函数在与STL算法匹配时的问题

silently 2004-02-27 11:11:53
在做编译器作业时,我为符号表写了一个类,重载了函数<
class Symbol
{
......
bool operator< (Symbol& str){
return this->s.first < str.symValue();//这两个操作数都是string型的
}
在我调用lower_bound()算法时出现了问题

i = lower_bound(table.begin(), table.end(), s);
[C++ Error] _function_base.h(73): E2093 'operator<' not implemented in type 'Symbol' for arguments of the same type

我明明已经重载了操作符operator<,为什么出现这种提示呢?
其中table的类型为vector<Symbol>,s的类型为Symbol
...全文
36 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复

24,855

社区成员

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

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