std::unordered_map - 未定义模板的隐式实例化

std::unordered_map - Implicit instantiation of undefined template?

本文关键字:实例化 未定义 unordered map std      更新时间:2023-10-16

我已经做过很多语言,但我是C++新手,我对如何初始化类实例完全感到困惑。以下代码在

class MyClass
{
   public:
    //Hash map variable
    //ERROR BELOW
    std::unordered_map<int, float, std::hash<int>, std::equal_to<int>, std::allocator<int>> myUnorderedMap;
}

我想我填写的模板不正确。任何帮助都会很棒。

您需要包含库标头:

#include <unordered_map>

并且您不需要在声明中放置默认类型:

std::unordered_map<int, float> myUnorderedMap;