this is my sample files
test.h
#ifndef _TEST
#define _TEST
template <class T>
class res_mgr
{
public:
res_mgr();
~res_mgr();
int load_all();
};
#endif
test.cpp
#include "test.h"
template<class T>
res_mgr<T>::res_mgr()
{
}
template<class T>
res_mgr<T>::~res_mgr()
{
}
template<class T>
int res_mgr<T>::load_all()
{
return 0;
}
main.cpp
#include "test.h"
int main(int argc, char** argv)
{
res_mgr<int> mgr;
return 0;
}
I compiled the project, and I got something like these:
[color="#0000FF"]--------------------Configuration: cpp_test - Win32 Debug--------------------
Compiling...
main.cpp
test.cpp
Linking...
main.obj : error LNK2001: unresolved external symbol "public: __thiscall res_mgr<int>::~res_mgr<int>(void)" (??1?$res_mgr@H@@QAE@XZ)
main.obj : error LNK2001: unresolved external symbol "public: __thiscall res_mgr<int>::res_mgr<int>(void)" (??0?$res_mgr@H@@QAE@XZ)
Debug/cpp_test.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.
cpp_test.exe - 3 error(s), 0 warning(s)
[color="#000000"]EDIT:
[color="#000000"]I've googled to look up some c++ template tutorials so I can compare my code with theirs, but it seems that my code is just fine. I don't understand what caused the errors, can you guys shed some lights on this?
Btw I use the oldie MSVC6.0