• 博客园logo
  • 会员
  • 周边
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
张纯睿
博客园    首页    新随笔    联系   管理    订阅  订阅

error LNK2001: 无法解析的外部符号 "public: static class stdext::hash_map

inline size_t CString_hash_value( const CString& str) /*const*/
{ 
   size_t value = _HASH_SEED; 
   size_t size  = str.GetLength(); 
   if (size > 0) { 
  size_t temp = (size / 16) + 1; 
  size -= temp; 
  for (size_t idx = 0; idx <= size; idx += temp) { 
    value += (size_t)str[(int)idx]; 
  } 
   } 
   return(value); 
}

class CString_hash_compare : public hash_compare<CString> 
{ 
public:


 size_t operator()(const CString& _Key) const 
 { 
  return((size_t)CString_hash_value(_Key));
 }

 bool operator()(const CString& _Keyval1, const CString& _Keyval2) const 
 { 
  return (comp(_Keyval1, _Keyval2)); 
 } 
};

class CUsers

{

static hash_map<CString, CUser *, CString_hash_compare> UserMap m_users;

}

调用失败!!!

错误 1 error LNK2001: 无法解析的外部符号 "public: static class stdext::hash_map<class ATL::CStringT<wchar_t,class StrTraitMFC_DLL<wchar_t,class ATL::ChTraitsCRT<wchar_t> > >,class CUser *,class CString_hash_compare,class std::allocator<struct std::pair<class ATL::CStringT<wchar_t,class StrTraitMFC_DLL<wchar_t,class ATL::ChTraitsCRT<wchar_t> > > const ,class CUser *> > > CUsers::m_users" (?m_users@CUsers@@2V?$hash_map@V?$CStringT@_WV?$StrTraitMFC_DLL@_WV?$ChTraitsCRT@_W@ATL@@@@@ATL@@PAVCUser@@VCString_hash_compare@@V?$allocator@U?$pair@$$CBV?$CStringT@_WV?$StrTraitMFC_DLL@_WV?$ChTraitsCRT@_W@ATL@@@@@ATL@@PAVCUser@@@std@@@std@@@stdext@@A) XQBot.obj

解决方案

 

将

static hash_map<CString, CUser *, CString_hash_compare> UserMap m_users;

改为

hash_map<CString, CUser *, CString_hash_compare> UserMap m_users;

posted @ 2011-06-21 19:00  张纯睿  阅读(1951)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3