Hope some one could help me with this very trivial error which I have not idea how to proceed :)
Here's the header file:
#ifndef __InputHandler__
#define __InputHandler__
#include "SDL.h"
#include <SDL_image.h>
#include <vector>
#include <iostream>
enum mouse_buttons {
LEFT = 0,
MIDDLE = 1,
RIGHT = 2,
};
class InputHandler {
public:
bool getMouseButtonState(int buttonNumber) {
return m_mouseButtonStates[buttonNumber];
}
std::vector<bool> m_mouseButtonStates;
static InputHandler* Instance() {
if (s_pInstance == 0) {
s_pInstance = new InputHandler();
}
return s_pInstance;
}
void update();
void clean();
private:
InputHandler();
~InputHandler() {}
static InputHandler* s_pInstance;
};
#endif
And I call the InputHandler::Instance() function in another class definition Player.cpp
#include "InputHandler.h"
void Player::handleInput() {
if (InputHandler::Instance()->getMouseButtonState(LEFT)) {
m_velocity.setX(1);
}
}
Here's the error that I get:
Player.obj : error LNK2001: unresolved external symbol
"private: static class InputHandler * InputHandler::s_pInstance"
I honestly don't know what's going on and what the error is pointing to. REALLY REALLY appreciate your wisdom :)))