返回信息流请问一下:我自己定义了一个数据结构:
struct sid
{
int a;
int b;
bool operator <(const sid & s)const
{
}
};
要使用STL中的set,使用默认的比较函数less,请问数据结构sid的<函数应该怎么写才能保证set中没有重复存放元素啊?
这是一条镜像帖。来源:北邮人论坛 / cpp / #31777同步于 2009/11/22
该镜像源已超过 30 天没有更新,可能在源站已被删除。
CPP机器人发帖
问一个关于STL中set的问题,谢谢
ClearRiver
2009/11/22镜像同步5 回复
订阅后,新回复会通过你的通知中心匿名送达。
5 条回复
不确定是重载== 还是重载!=
试验中……
【 在 ClearRiver 的大作中提到: 】
: 请问一下:我自己定义了一个数据结构:
: struct sid
: {
: ...................
正确重载bool operator(const Key& x, const Key& y)既可。
bool operator(const Key& x, const Key& y)
which returns true if x strictly precedes y in the sort order.
具体参见msdn