Hello everyone.
I am trying to write a game in C++ with SDL, and I have a class that allows me to handle events.
The class is actually really simple: It takes the SDL_Event, then 2 variables from 2 different enum to determine for which Event and which Key should be checked, and then a variable that will be modified if the event happens.
Here is the class
EventParser.h
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
#include "SDL.h"
#include "SDL_opengl.h"
template<class T>
class EventParser
{
public:
enum EventType{
KeyUp, KeyDown
};
enum KbdKey{
LEFT, RIGHT, UP, DOWN
};
void parseEvent(SDL_Event e, EventType t, KbdKey k, T* var);
};
|
EventParser.cpp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
#include "EventParser.h"
template<class T>
void EventParser<T>::parseEvent(SDL_Event e, EventType t, KbdKey k, T* var)
{
switch (t)
{
case t.KeyUp:
switch (k)
{
case: k.LEFT:
&var -= 1.0;
default:
break;
}
default:
break;
}
}
|
As of yet the variable only changes if the Left key has been released, it will be extended if the error has been solved.
Then, in my main.cpp file I define the Event and the EventParser as
1 2
|
SDL_Event event;
EventParser<float> ep;
|
And in a loop, the parseEvent function is called like this:
ep.parseEvent(event, ep.KeyUp, ep.LEFT, &xVariable);
However I get a linker error (not the first one I got when programming this game)
error LNK2019: unresolved external symbol "public: void __thiscall EventParser<float>::parseEvent(union SDL_Event,enum EventParser<float>::EventType,enum EventParser<float>::KbdKey,float *)" (?parseEvent@?$EventParser@M@@QAEXTSDL_Event@@W4EventType@1@W4KbdKey@1@PAM@Z) referenced in function _SDL_main C:\Users\PrideRage\Documents\Visual Studio 2012\Projects\SDL_Test\SDL_Test\main.obj SDL_Template
I have tried searching but I haven't found any solution that helped me here.
Thanks in advance for helping me.