MyClass.h
class MyClass
{
//...
public:
template <class T>
static void Swap(T& Var1, T& Var2);
//...
}
MyClass.cpp
template <class T>
void MyClass::Swap( T& Var1, T& Var2 )
{
Var1 ^= Var2;
Var2 ^= Var1;
Var1 ^= Var2;
}
In another file
#include "MyClass.h"
//...
int n = 40;
int m = 60;
StringOperations::Swap(n, m); // IF I DELETE THIS LINE, ERROR MESSAGE DISAPPEARS
//...
This code gives this error:
Error 1 MyClassCallee.obj error LNK2019: unresolved external symbol "public: static void __cdecl MyClass::Swap<int>(int &,int &)" (??$Swap@H@MyClass@@SAXAAH0@Z) referenced in function "protected: void __thiscall MyClassCallee::SwapTest(void)" (?SwapTest@MyClassCallee@@IAEXXZ)
I'm lost, what can I do to correct this error?