这是我一直遇到的错误,我一直在试图弄清楚如何解决它但失败了。我在问是否有人可以指出我正确的方向。
WorldServer fatal error LNK1120: 2 unresolved externals
WorldServer error LNK2019: unresolved external symbol "public: class CItemElem * __thiscall CLinkedItemMgr::GetLinkedItem(unsigned long)" (?GetLinkedItem@CLinkedItemMgr@@QAEPAVCItemElem@@K@Z) referenced in function "private: void __thiscall CDPSrvr::OnLinkedItem(class CAr &,unsigned long,unsigned long,unsigned char *,unsigned long)" (?OnLinkedItem@CDPSrvr@@AAEXAAVCAr@@KKPAEK@Z)
WorldServer error LNK2019: unresolved external symbol "public: int __thiscall CLinkedItemMgr::AddLinkedItem(class CItemElem *)" (?AddLinkedItem@CLinkedItemMgr@@QAEHPAVCItemElem@@@Z) referenced in function "private: void __thiscall CDPSrvr::OnLinkedItem(class CAr &,unsigned long,unsigned long,unsigned char *,unsigned long)" (?OnLinkedItem@CDPSrvr@@AAEXAAVCAr@@KKPAEK@Z)
这是.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;
}