template operator== not working
This is my XYZ_POINT.h file
template<typename T>
class XYZ_POINT
{
private:
T x;
T y;
T z;
public:
XYZ_POINT(void) {};
XYZ_POINT(const T allVals) : x(allVals), y(allVals), z(allVals) {};
bool const operator==(const XYZ_POINT<T> &xyzTest);
}
In my cpp file I have this.
template<typename T>
bool const XYZ_POINT<T>::operator ==(const XYZ_POINT<T> &xyzTest)
{
return ((x == xyzTest.GetX()) &&(y == xyzTest.GetY()) &&(z ==
xyzTest.GetZ()));
}
In the main file I have this
int _tmain(int arc, _TCHAR* argv[])
{
XYZ_POINT<double> dXYZPnt1(1,0,0);
XYZ_POINT<double> dXYZPnt2(3,0,0);
if (dXYZPnt1 == dXYZPnt2)
{
bool b = true;
b = false;
}
}
Doesn't compile with the following error
error LNK2019: unresolved external symbol "public: bool const __thiscall
XYZ_POINT<double>::operator==(class XYZ_POINT<double> const &)"
(??8?$XYZ_POINT@N@@QAE?B_NABV0@@Z) referenced in function _main
If I move the implimentation to the header file it compiles fine.
What am I doing wrong?
The actual implimentation is more complex then I'm demonstrating and I need
to include some header files that I don't want in the declaration.
Thanks
Mark