Hi, i'd like to use a Template as a placeholder for a argument type. Like:
function(int arg1, T arg2)
my header file looks as following:
Code:
class MyClass
{
public:
template <typename T>
bool MyFunction(int arg1, T arg2);
}
this is my class.cpp code;
Code:
template <typename T>
bool MyClass::MyFunction(int arg1, T arg2)
{
if (arg1 > arg2)
return true;
else
return false;
}
i call this function as following:
Code:
MyClass MyClass; //create object
MyClass.MyFunction<float>(int arg1, float arg2);
but it simply wont work..
Can somebody help me please?
How can i implement this if i have more than one source file...?
This is the error output...
Code:
1>main.obj : error LNK2001: unresolved external symbol ""public: bool __thiscall MyClass::MyFunction<float>(unsigned int,float)" (??$MyFunction@M@MyClass@@QAE_NIIIIIM@Z)".
EDIT: It won't even work if i define all members as 'inline'...
EDIT2: Yes i know it works if i put the whole code into the header file.. but lulz .. thats not clean