Une petite erreur de création de templates
Bonjour,
j'ai ecrit le code suivant dans visual C++
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
|
Point.h
template <class T> class Point
{
private:
T x;
T y;
public:
Point();
virtual ~Point();
Point(T a, T b);
void afficher();
void deplacer(T dx, T dy);
};
Point.cpp
#include "Point.h"
#include "iostream.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
template <class T> Point<T>::Point()
{
}
template <class T> Point<T>::~Point()
{
}
template <class T> Point <T>::Point(T a, T b)
{
x=a;
y=b;
}
template <class T> void Point<T> ::afficher()
{
cout<<x<<" "<<y<<endl;
}
template < class T> void Point<T>::deplacer(T dx, T dy)
{
x+=dx;
y+=dy;
}
Main
#include "Point.h"
int main(int argc, char* argv[])
{
Point<int> p(2,7);
p.afficher();
return 0;
} |
J'ai reçu le message d'erreur suivant
--------------------Configuration: gggaaa - Win32 Debug--------------------
Linking...
gggaaa.obj : error LNK2001: unresolved external symbol "public: virtual __thiscall Point<int>::~Point<int>(void)" (??1?$Point@H@@UAE@XZ)
gggaaa.obj : error LNK2001: unresolved external symbol "public: void __thiscall Point<int>::afficher(void)" (?afficher@?$Point@H@@QAEXXZ)
gggaaa.obj : error LNK2001: unresolved external symbol "public: __thiscall Point<int>:: Point<int>(int,int)" (??0?$Point@H@@QAE@HH@Z)
Debug/gggaaa.exe : fatal error LNK1120: 3 unresolved externals
Error executing link.exe.
gggaaa.exe - 4 error(s), 0 warning(s)
Est ce quelqu'un peut m'aider?
merci