[STL ] hash_map和VC 2005的問題

看板Programming作者 (平衡)時間18年前 (2006/11/16 12:51), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/3 (看更多)
※ [本文轉錄自 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
文章代碼(AID): #15M-vboE (Programming)
文章代碼(AID): #15M-vboE (Programming)