I'm getting an unresolved external error, but can't figure out why. I'm implementing a singleton according to this site https://refactoring.guru/design-patterns/singleton/cpp/example. My header contains this
class GameLoop {
private:
static GameLoop* instance;
public:
GameLoop(GameLoop& other) = delete;
void operator=(const GameLoop& other) = delete;
static GameLoop* GetInstance();
And my cpp contains this
#include "GameLoop.h"
GameLoop* GameLoop::instance = nullptr;
GameLoop* GameLoop::GetInstance() {
if (instance == nullptr)
instance = new GameLoop();
return instance;
}
I can't see what the problem with GetInstance is though.