C++ 在VS2008中,我试图定义散列映射变量的操作不起作用

C++ 在VS2008中,我试图定义散列映射变量的操作不起作用,c++,visual-studio-2008,hashmap,C++,Visual Studio 2008,Hashmap,我正在使用VisualStudio2008。这是我的代码: #include "stdafx.h" #include <conio.h> #include <hash_map> #include <iostream> using namespace std; hash_map <int, int> hm; int main() { return 0; } #包括“stdafx.h” #包括 #包括 #包括 使用名称空间std; ha

我正在使用VisualStudio2008。这是我的代码:

#include "stdafx.h"
#include <conio.h>
#include <hash_map>
#include <iostream>

using namespace std;

hash_map <int, int> hm;

int main()
{
    return 0;
}
#包括“stdafx.h”
#包括
#包括
#包括
使用名称空间std;
hash_映射hm;
int main()
{
返回0;
}
这是我的错误:

error C2143: syntax error : missing ';' before '<'
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

错误C2143:语法错误:缺少“;”在MSVC编译器中的“之前,标准库的扩展位于
stdext
命名空间中:

#include <hash_map>

stdext::hash_map<int, int> hm;

int main()
{
    return 0;
}
#包括
stdext::hash_映射hm;
int main()
{
返回0;
}
免责声明:我不拥有VS2008,但这应该可以使用。:)


但是请注意,如果可能的话,您应该更新到最新的编译器,并使用新的标准无序容器:
std::unordered_-map
std::unordered_-set

您没有发布真实代码,在真实代码中,哈希映射类型不是int/int,您需要提供默认的
操作符基本拼写和标点符号。即使你不是母语为英语的人,也要花点时间运行拼写检查和校对你的代码……在C++Er中没有
conio.h
hash_map
,演示可能不是最好的例子,但质量较低的问题已经得到了回答,这是可以回答的(我现在已经写了一个…)。投票重开。@EduardoLeón胡说。问题清楚地标记为这些标题实际上存在的位置。