我作为最后的手段来到这里,因为我需要帮助,因为明天将要分配一份作业。
我正在用C ++编写一个简单的引擎来处理节点,纹理/资产加载和状态系统。我想尝试继续编写资产相关的东西,但为了做到这一点,我需要州系统工作。
APPLICATION.h
#pragma once
#include "AppGSM\EGameStateManager.h"
class EGameStateManager;
class EApplication
{
public:
static void Init();
static void RunApp();
EGameStateManager* GetGameStateManager();
protected:
static int windowWidth;
static int windowHeight;
static bool fullScreen;
static bool frameSync;
static char* windowTitle;
};
目前每当我尝试使用上面看到的指针时,在我的teststate类和main.cpp中,我都会收到链接器错误。 (见下文)
TEST STATE.cpp
#include "AppGSM\ETestState.h"
#include "AppGSM\EApplication.h"
#include <iostream>
ETestState::ETestState(EApplication* pApp){}
ETestState::~ETestState(){}
void ETestState::Update(float deltaTime)
{
//if(INPUT::GetKey(KEY_T))
//{
// cout << "Entered Test State" << endl;
//}
m_testTimer += deltaTime;
if(m_testTimer > 3.0f)
{
m_pApp->GetGameStateManager()->ChangeState("Second TEST");
}
}
void ETestState::Draw(){}
的main.cpp
#include "GL\glew.h"
#include "GL\glfw.h"
#include <conio.h>
#include "AppGSM\EApplication.h"
#include "AppGSM\ETestState.h"
void main()
{
EApplication::Init();
EApplication* pApp = new EApplication();
pApp->GetGameStateManager()->SetState("TEST", new ETestState(pApp));
EApplication::RunApp();
}
这是基础游戏状态类,它包含在teststate中使用的应用程序指针:
BASEGAMESTATE.h
#pragma once
class EApplication;
class EGameStateManager;
class EBaseGameState
{
public:
EBaseGameState(){}
EBaseGameState(EApplication* pApp);
//always make the destructor virtual !!
virtual ~EBaseGameState();
//all game states must define update and draw
virtual void Update(float deltaTime) = 0;
virtual void Draw() = 0;
protected:
EApplication* m_pApp;
};
这些是链接器错误:
Error 9 error LNK2019: unresolved external symbol "public: class EGameStateManager * __thiscall EApplication::GetGameStateManager(void)" (?GetGameStateManager@EApplication@@QAEPAVEGameStateManager@@XZ) referenced in function _main D:\Engine\main.obj
Error 10 error LNK2001: unresolved external symbol "public: class EGameStateManager * __thiscall EApplication::GetGameStateManager(void)" (?GetGameStateManager@EApplication@@QAEPAVEGameStateManager@@XZ) D:\Engine\ETestState.obj
通常我会将链接器错误归结为循环包含,但我已经写下了各种类型的序列图,没有包含任何包含自身的内容。它可能是显而易见的......我真的很紧张。任何帮助将不胜感激。
答案 0 :(得分:1)
链接器无法找到该功能。您需要实现GetGameStateManager()函数