這是我一直在得到的錯誤,我一直在試圖找出如何解決它,但失敗了。我在問是否有人能指引我走向正確的方向。爲什麼我會收到此錯誤? 「無法解析的外部符號」
WorldServer fatal error LNK1120: 2 unresolved externals
WorldServer error LNK2019: unresolved external symbol "public: class CItemElem * __thiscall CLinkedItemMgr::GetLinkedItem(unsigned long)" ([email protected]@@[email protected]@[email protected]) referenced in function "private: void __thiscall CDPSrvr::OnLinkedItem(class CAr &,unsigned long,unsigned long,unsigned char *,unsigned long)" ([email protected]@@[email protected]@[email protected])
WorldServer error LNK2019: unresolved external symbol "public: int __thiscall CLinkedItemMgr::AddLinkedItem(class CItemElem *)" ([email protected]@@[email protected]@@Z) referenced in function "private: void __thiscall CDPSrvr::OnLinkedItem(class CAr &,unsigned long,unsigned long,unsigned char *,unsigned long)" ([email protected]@@[email protected]@[email protected])
這是.H
#ifndef __ITEM_LINK__H
#define __ITEM_LINK__H
class CLinkedItemMgr
{
private:
CLinkedItemMgr(){ m_dwLinkedItemCount = 0;};
~CLinkedItemMgr(){};
DWORD m_dwLinkedItemCount;
public:
map<DWORD,CItemElem*> m_mapLinkedItems;
static CLinkedItemMgr *GetInstance()
{
static CLinkedItemMgr instance;
return &instance;
}
int AddLinkedItem(CItemElem *pItem);
CItemElem *GetLinkedItem(DWORD dwIndex);
};
#endif
這是在.cpp
#include "stdafx.h"
#include "ItemLink.h"
int CLinkedItemMgr::AddLinkedItem(CItemElem *pItem)
{
if(!pItem)
return 0;
m_mapLinkedItems.insert(make_pair<DWORD,CItemElem*>(++m_dwLinkedItemCount,pItem));
return m_dwLinkedItemCount;
}
CItemElem *CLinkedItemMgr::GetLinkedItem(DWORD dwIndex)
{
map<DWORD,CItemElem*>::iterator it = m_mapLinkedItems.find(dwIndex);
if(it == m_mapLinkedItems.end())
return FALSE;
return it->second;
}
你在哪裏定義'AddLinkedItem'? –
你包括警衛是保留的標識符:http://stackoverflow.com/questions/228783/what-are-the-rules-about-using-an-underscore-in-ac-identifier – chris