G
Guest
Hi, All
I am migrating to Studio .NET 2003 from Studio 6.0 and Studio .NET 2002. When I compiled my code, which is compilable both in VC++ 6.0 and Studio .NET 2002, I have an error LNK2019 as the following
-------------------------------------------------------------------------
error LNK2019: unresolved external symbol "class CPV3<double> __cdecl operator*(double,class CPV3<double> const &)" (??D@YA?AV?$CPV3@N@@NABV0@@Z) referenced in function _mai
-------------------------------------------------------------------------
The error is related to a template function! Does any body have any idea to solve this problem
#include "stdafx.h
#include "PV3.h
int _tmain(int argc, _TCHAR* argv[]
CPV3<double> aVec, bVec
aVec.x = 1.0
aVec.y = 2.0
aVec.z = 3.0
bVec.x = 2.0
bVec.y = 2.0
bVec.z = 2.0
aVec = 2.0*bVec; // error LNK2019: unresolved external symbol
Swap(bVec,aVec); // this function works wel
return 0
// -------------------------------
// file "PV.h
template< class T
class CPV
// Attribute
public
/
unio
struc
T x
T y
T z
}
}
// Method
public
CPV3()
~CPV3()
friend CPV3<T> operator * ( const double dMul, const CPV3<T>& a )
friend void Swap( const CPV3<T>& a, const CPV3<T>& b )
}
template< class T
CPV3<T>::CPV3(
template< class T
CPV3<T>::~CPV3(
template< class T
CPV3<T> operator * ( const double dMul, const CPV3<T>& a
CPV3<T> pv( a )
pv.x *= dMul; pv.y *= dMul; pv.z *= dMul
return pv
template< class T
void Swap( CPV3<T>& a, CPV3<T>& b
CPV3<T> tmp(a)
a = b
b = tmp
// ------ end of file PV.h --------
// --------------------------------
// File PV.cp
#include "stdafx.h
#include "PV3.h
template class CPV3< double >
template CPV3<double> operator * ( const double dMul
const CPV3<double>& a )
template void Swap( CPV3<double>& a, CPV3<double>& b )
// ------- Enf of file PV.cpp --------
I am migrating to Studio .NET 2003 from Studio 6.0 and Studio .NET 2002. When I compiled my code, which is compilable both in VC++ 6.0 and Studio .NET 2002, I have an error LNK2019 as the following
-------------------------------------------------------------------------
error LNK2019: unresolved external symbol "class CPV3<double> __cdecl operator*(double,class CPV3<double> const &)" (??D@YA?AV?$CPV3@N@@NABV0@@Z) referenced in function _mai
-------------------------------------------------------------------------
The error is related to a template function! Does any body have any idea to solve this problem
#include "stdafx.h
#include "PV3.h
int _tmain(int argc, _TCHAR* argv[]
CPV3<double> aVec, bVec
aVec.x = 1.0
aVec.y = 2.0
aVec.z = 3.0
bVec.x = 2.0
bVec.y = 2.0
bVec.z = 2.0
aVec = 2.0*bVec; // error LNK2019: unresolved external symbol
Swap(bVec,aVec); // this function works wel
return 0
// -------------------------------
// file "PV.h
template< class T
class CPV
// Attribute
public
/
unio
struc
T x
T y
T z
}
}
// Method
public
CPV3()
~CPV3()
friend CPV3<T> operator * ( const double dMul, const CPV3<T>& a )
friend void Swap( const CPV3<T>& a, const CPV3<T>& b )
}
template< class T
CPV3<T>::CPV3(
template< class T
CPV3<T>::~CPV3(
template< class T
CPV3<T> operator * ( const double dMul, const CPV3<T>& a
CPV3<T> pv( a )
pv.x *= dMul; pv.y *= dMul; pv.z *= dMul
return pv
template< class T
void Swap( CPV3<T>& a, CPV3<T>& b
CPV3<T> tmp(a)
a = b
b = tmp
// ------ end of file PV.h --------
// --------------------------------
// File PV.cp
#include "stdafx.h
#include "PV3.h
template class CPV3< double >
template CPV3<double> operator * ( const double dMul
const CPV3<double>& a )
template void Swap( CPV3<double>& a, CPV3<double>& b )
// ------- Enf of file PV.cpp --------