B
Bob Altman
Hi all,
This is the first time I've tried to create a templatized function, and I
can't get past a linker error. I create a new, unmanaged C++ application
and added a class named MyClass. In MyClass.h I added:
template <class T> void MyFunc(T);
In MyClass.cpp I added:
template <class T> void MyClass::MyFunc(T)
{
cout << T << endl;
}
In the main program, I added:
MyClass t;
t.MyFunc(25);
When I build the project, the compiler is happy, but the linker says:
Unresolved external symbol "public: void __thiscall
MyClass::MyFunc<int>(int)"
What have I missed?
(BTW, I just want to take a moment to thank the good folks who have been
answering my many questions in the NG recently. You guys are great!)
This is the first time I've tried to create a templatized function, and I
can't get past a linker error. I create a new, unmanaged C++ application
and added a class named MyClass. In MyClass.h I added:
template <class T> void MyFunc(T);
In MyClass.cpp I added:
template <class T> void MyClass::MyFunc(T)
{
cout << T << endl;
}
In the main program, I added:
MyClass t;
t.MyFunc(25);
When I build the project, the compiler is happy, but the linker says:
Unresolved external symbol "public: void __thiscall
MyClass::MyFunc<int>(int)"
What have I missed?
(BTW, I just want to take a moment to thank the good folks who have been
answering my many questions in the NG recently. You guys are great!)