Original Post
Hello everyone
I'm writing an input managing class, and I've stumbled upon a problem right now. I've been trying to fix it for a long time, but I just don't see the problem. It's probably a minor detail (like always.. -.-), but I would really apreciate it if someone could take a look at it.
The error I'm getting is:
Error 13 error LNK2001: unresolved external symbol "private: static struct Input::Keyinfo * Input::KeyinfoArr" (?KeyinfoArr@Input@@0PAUKeyinfo@1@A) C:\Nick\D3D projects\DVD\Code\Chapter 25 Character Animation\SkinnedMesh\InputManager.obj
[source lang="cpp"]header file:
struct Input
{
//...some code
public:
enum Action{
MOVEFORWARD,
MOVEBACKWARD,
STRAFELEFT,
STRAFERIGHT,
JUMP};
static bool AllowAction(Action action);
private: //...some code
static const int ACTIONCOUNT = 5; // amount of possible controls/actions
struct Keyinfo
{
Action action;
int code; // virtual-key code associated with action
bool pressed;
bool down;
};
static Keyinfo KeyinfoArr[ACTIONCOUNT];
};
cpp file:
//...some code
bool Input::AllowAction(Action action)
{
for (int i = 0; i < ACTIONCOUNT; ++i)
{
if (KeyinfoArr.action == action)
{
if ((KeyinfoArr.action == Action::MOVEFORWARD ||
KeyinfoArr.action == Action::MOVEBACKWARD ||
KeyinfoArr.action == Action::STRAFELEFT ||
KeyinfoArr.action == Action::STRAFELEFT)
&& KeyinfoArr.down)
return true;
if (KeyinfoArr.action == Action::MOVEFORWARD && KeyinfoArr.pressed)
return true;
}
}
return false;
}[/source]
I'm writing an input managing class, and I've stumbled upon a problem right now. I've been trying to fix it for a long time, but I just don't see the problem. It's probably a minor detail (like always.. -.-), but I would really apreciate it if someone could take a look at it.
The error I'm getting is:
Error 13 error LNK2001: unresolved external symbol "private: static struct Input::Keyinfo * Input::KeyinfoArr" (?KeyinfoArr@Input@@0PAUKeyinfo@1@A) C:\Nick\D3D projects\DVD\Code\Chapter 25 Character Animation\SkinnedMesh\InputManager.obj
[source lang="cpp"]header file:
struct Input
{
//...some code
public:
enum Action{
MOVEFORWARD,
MOVEBACKWARD,
STRAFELEFT,
STRAFERIGHT,
JUMP};
static bool AllowAction(Action action);
private: //...some code
static const int ACTIONCOUNT = 5; // amount of possible controls/actions
struct Keyinfo
{
Action action;
int code; // virtual-key code associated with action
bool pressed;
bool down;
};
static Keyinfo KeyinfoArr[ACTIONCOUNT];
};
cpp file:
//...some code
bool Input::AllowAction(Action action)
{
for (int i = 0; i < ACTIONCOUNT; ++i)
{
if (KeyinfoArr.action == action)
{
if ((KeyinfoArr.action == Action::MOVEFORWARD ||
KeyinfoArr.action == Action::MOVEBACKWARD ||
KeyinfoArr.action == Action::STRAFELEFT ||
KeyinfoArr.action == Action::STRAFELEFT)
&& KeyinfoArr.down)
return true;
if (KeyinfoArr.action == Action::MOVEFORWARD && KeyinfoArr.pressed)
return true;
}
}
return false;
}[/source]