I have been trying to implement a simple singleton, however I am getting a unresolved external:
error LNK2001: unresolved external symbol "private: static class Xeno::Engine * Xeno::Engine::m_instance" (?m_instance@Engine@Xeno@@0PAV12@A)
I looked around online for a while looking at examples on singleton classes, however I can't seem to find anything wrong with what I am trying to do.
Here's my header file:
#pragma once
namespace Xeno {
class Engine
{
private:
Engine();
static Engine* m_instance;
protected:
public:
~Engine();
static Engine* GetInstance()
{
if (m_instance == nullptr)
m_instance = new Engine();
return m_instance;
}
void TestFunc();
};
}
And here's my cpp file:
#include "Engine.h"
namespace Xeno {
Engine* Engine::m_instance = nullptr;
Engine::Engine()
{
}
Engine::~Engine()
{
}
void Engine::TestFunc()
{
}
}