【发布时间】:2013-06-10 04:30:21
【问题描述】:
我正在做一个任务,我在 C++ 中实现一个字典 (ADT)。我最初用 Xcode 编写程序,一切似乎都运行良好。但是我最近发现分级机使用 Visual Studio 2010,所以我试图确保我的代码也能在 VS2010 中运行......
我现在遇到的问题是我的 remove() 哈希表函数。基本上,我使用列表向量并遍历列表以删除冲突条目。但是现在当我尝试测试这个remove() 函数时,我收到以下错误:debug assertion failed! expression list iterators incompatible。我尝试查看有关断言的 Visual C++ 文档,一切看起来都应该可以工作....有什么我忽略了吗?
这是我的代码:
///**DELETE***////
void remove(string key) {
size_t index = hashString(key);
list<Entry>& entry = table.at(index);
for(typename list<Entry>::iterator it = entry.begin();
it != entry.end();
/**/)
{
if (it->data == key) {
table[index].erase(it);
} else
it++;
}
//entry not found
cout << "Error: Cannot Delete... No Such Entry"<< endl;
}
【问题讨论】:
-
断言发生在哪一行?
标签: c++ visual-studio-2010 assert visual-studio-debugging