Bonjour

je m'essaye aux templates mais ce n'est pas concluant.

J'ai declaré la chose comme ca dans mon .h:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
 
class CCardData
{
public:
template<typename T>
	BOOL SetNumeric(CString csKey, T nValue);
}
et dans mon cpp
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
 
template<typename T>
BOOL CCardData::SetNumeric(CString csKey, T nValue)
{
	return TRUE;
}
Quand j'appele la methode comme ceci
m_card.SetNumeric( _T("NumPorteur"), m_usNumPorteur );

j'ai une erreur du compilo :

PersoCongres error LNK2019: unresolved external symbol "public: int __thiscall CCardData::SetNumeric<int>(class ATL::CStringT<char,class StrTraitMFC_DLL<char,class ATL::ChTraitsCRT<char> > >,int)" (??$SetNumeric@H@CCardData@@QAEHV?$CStringT@DV?$StrTraitMFC_DLL@DV?$ChTraitsCRT@D@ATL@@@@@ATL@@H@Z) referenced in function "private: void __thiscall CPersoCongresDlg::ScreenToCardInfo(void)" (?ScreenToCardInfo@CPersoCongresDlg@@AAEXXZ)