4

私はVisual Studio 2008を使用しています。これは私のコードです:

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

using namespace std;

hash_map <int, int> hm;

int main()
{
    return 0;
}

そして、ここに私のエラーがあります:

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

1 に答える 1

5

MSVC コンパイラでは、標準ライブラリの拡張機能はstdext名前空間に配置されます。

#include <hash_map>

stdext::hash_map<int, int> hm;

int main()
{
    return 0;
}

免責事項: 私は VS2008 を所有していませんが、これで動作するはずです。:)

ただし、可能であれば最新のコンパイラに更新し、代わりに新しい標準の順不同コンテナを使用する必要があることに注意してください:std::unordered_mapおよびstd::unordered_set.

于 2013-01-14T23:45:12.977 に答える