You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Hash Table重哈希函数报错及operator[]问题求助

哈希表作业re-hash实现中的问题求助

问题背景与错误信息

我正在完成哈希表作业,实现re-hash函数时触发了如下运行时错误:

terminate called after throwing an instance of 'std::logic_error'
  what():  basic_string::_M_construct null not valid
Aborted (core dumped)

查阅相关资料后仍未理解错误根源。尝试创建新的CovidDB对象来重哈希现有条目时,编译器提示'operator[]'未定义;改用二维std::vector<std::vector<DataEntry*>>可以运行,但我认为这并非正确的实现方案。我已经按照五法则实现了拷贝构造、移动构造、重载赋值运算符等函数,问题依然存在。

需要解答的问题

  • 触发上述std::logic_error的具体原因
  • 为何在add函数中可正常使用HashTable的[]运算符,但在re-hash中操作CovidDB对象时却报错operator[]未定义

内容的提问来源于stack exchange,提问作者i_hate_F_sharp

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.20 10:18:12