我收到LNK2001错误。该代码已包含在下面。有人可以帮我吗?
Error 3 error LNK2001: unresolved external symbol "private: static class std::vector<struct _UpdateAction,class std::allocator<struct _UpdateAction> > InstrumentCache::actionTaken" (?actionTaken@InstrumentCache@@0V?$vector@U_UpdateAction@@V?$allocator@U_UpdateAction@@@std@@@std@@A) PerformanceTest.obj
//UpdateAction.h
typedef struct _UpdateAction
{
enum FIS_ACTION {
ADDED,
UPDATED,
DELETED
};
int id;
int type;
int legacyType;
FIS_ACTION action;
}UpdateAction;
typedef std::vector<UpdateAction> ActionTakenVector;
// InstrumentCache.h
#include UpdateAction.h
class InstrumentCache
{
public:
static ActionTakenVector& GetApplicationUpdateVector ()
{
return actionTaken;
}
static void ClearApplicationUpdateVector()
{
actionTaken.clear();
}
private:
static ActionTakenVector actionTaken;
};
//fisClient.h
#include "UpdateAction.h"
#include "InstrumentCache.h"
class FISClient
{
void FunctionOne()
{
ActionTakenVector& rV = InstrumentCache::GetApplicationUpdateVector();
InstrumentCache::ClearApplicationUpdateVector();
}
} ;
PerformanceTest.cpp
#include "fisClient.h"
最佳答案
似乎您缺少actionTaken的定义(该类中的声明还不够)。是否添加
ActionTakenVector InstrumentCache :: actionTaken;
在PerformanceTest.cpp中有帮助吗?