【发布时间】:2009-05-04 16:40:27
【问题描述】:
我正在尝试确定一个对象是否已包含在 std::set 中。根据 msdn(和其他来源),如果 set::find 函数没有找到您要求的元素,它应该返回 end()。
但是,当我实现如下代码时,set::find 会返回垃圾 (0xbaadf00d)。
set<Cell*> cellSet;
Cell* cell = new Cell();
if (cellSet.find(cell) == cellSet.end())
{
...
}
我使用正确吗?我正在使用 Visual C++ 2005。
【问题讨论】: