Probleme Avec les templates
Salut a tous
voila je suis entrain d'apprendre la manipulation des templates
je travaille sous VC++ , quand j'appelle mon constructeur ça me donne un beug voici un petit exemple
La classe Test.h
Code:
1 2 3 4 5 6 7 8 9
|
template<class Type>
class Test
{
public:
Test();
virtual ~Test();
void add();
}; |
La classe test.cpp
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| #include "stdafx.h"
#include "Test.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
template<class Type>
Test<Type>::~Test()
{
}
template<class Type>
Test<Type>::Test()
{
}
template<class Type>
void Test<Type>::add()
{
} |
Le Main
Code:
1 2 3 4 5 6 7 8
| #include "stdafx.h"
#include "Test.h"
int main(int argc, char* argv[])
{
Test<int> k;
return 0;
} |
l'Erreur
Code:
1 2 3 4 5 6 7 8 9 10
| --------------------Configuration: Test33 - Win32 Debug--------------------
Compiling...
Test33.cpp
Linking...
Test33.obj : error LNK2001: unresolved external symbol "public: virtual __thiscall Test<int>::~Test<int>(void)" (??1?$Test@H@@UAE@XZ)
Test33.obj : error LNK2001: unresolved external symbol "public: __thiscall Test<int>::Test<int>(int const &)" (??0?$Test@H@@QAE@ABH@Z)
Debug/Test33.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.
Test33.exe - 3 error(s), 0 warning(s) |