作者Linvail (平衡)
看板Programming
标题[STL ] hash_map和VC 2005的问题
时间Thu Nov 16 12:51:48 2006
※ [本文转录自 C_and_CPP 看板]
作者: Linvail (平衡) 看板: C_and_CPP
标题: [STL ] hash_map和VC 2005的问题
时间: Thu Nov 16 12:51:04 2006
我的环境是VC++ 2005 Express 和MS Platform SDK for Windows Server 2003 R2
我可以正常编译和使用<vector> <algorithm>,但是include <hash_map>就会出现
一大堆错误,错误都是出现在非我写的那些档案上
请问有没有人能协助解决问题呢?
例如我编译以下MSDN提供的范例:
在这些档案上都有错误 xhash, hash_map, xlocinfo.h
举几个在xhash上的错误:
C:\Program Files\Microsoft Visual Studio 8\VC\include\xhash(41) : error
C2143: 语法错误 : 遗漏 ';' (在 ''template<'' 之前)
C:\Program Files\Microsoft Visual Studio 8\VC\include\xhash(41) : error
C4430: 遗漏型别规范 - 假设为 int。注意: C++ 不支援 default-int
// hash_map_count.cpp
// compile with: /EHsc
#define _DEFINE_DEPRECATED_HASH_CLASSES 0
#include <hash_map>
#include <iostream>
int main()
{
using namespace std;
using namespace stdext;
hash_map<int, int> hm1;
hash_map<int, int>::size_type i;
typedef pair<int, int> Int_Pair;
hm1.insert(Int_Pair (1, 1));
hm1.insert(Int_Pair (2, 1));
hm1.insert(Int_Pair (1, 4));
hm1.insert(Int_Pair (2, 1));
// Keys must be unique in hash_map, so duplicates are ignored
i = hm1.count(1);
cout << "The number of elements in hm1 with a sort key of 1 is: "
<< i << "." << endl;
i = hm1.count(2);
cout << "The number of elements in hm1 with a sort key of 2 is: "
<< i << "." << endl;
i = hm1.count(3);
cout << "The number of elements in hm1 with a sort key of 3 is: "
<< i << "." << endl;
}
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.114.79.108
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.114.79.108