代码中的LNK2001错误

我收到了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帮助?     
静态成员需要初始化。在课堂外的某个地方,你应该写
ActionTakenVector InstrumentCache::actionTaken
,它应该初始化那个静态字段并消除你的错误。     

要回复问题请先登录注册