Ask a problem,about template:)
-
Ask a problem,about template:) i write template class <<<<<<<<>>>>>>> #pragma once template class Tem { public: T rxg(T a); }; <<<<<<<<>>>>>>> #include "stdafx.h" #include "class.h" templateT Tem::rxg(T a) { return a; } <<<<<<<<<<>>>>>>>> #include "Class.h" ................................ Tem moral; int a=moral.rxg(10); Error: Test.obj : error LNK2019: unresolved external symbol "public: int __thiscall Tem::rxg(int)" (?rxg@?$Tem@H@@QAEHH@Z) referenced in function "public: void __thiscall CAboutDlg::OnBnClickedOk(void)" (?OnBnClickedOk@CAboutDlg@@QAEXXZ) thank:)
-
Ask a problem,about template:) i write template class <<<<<<<<>>>>>>> #pragma once template class Tem { public: T rxg(T a); }; <<<<<<<<>>>>>>> #include "stdafx.h" #include "class.h" templateT Tem::rxg(T a) { return a; } <<<<<<<<<<>>>>>>>> #include "Class.h" ................................ Tem moral; int a=moral.rxg(10); Error: Test.obj : error LNK2019: unresolved external symbol "public: int __thiscall Tem::rxg(int)" (?rxg@?$Tem@H@@QAEHH@Z) referenced in function "public: void __thiscall CAboutDlg::OnBnClickedOk(void)" (?OnBnClickedOk@CAboutDlg@@QAEXXZ) thank:)
When you make a class template you need to globaly define the object type you are using in the class.h there are other ways to solve this also :- Look for class template instantiation. http://msdn2.microsoft.com/en-us/library/7y5ca42y.aspx[^]
Regards, FarPointer Blog:FARPOINTER
-
When you make a class template you need to globaly define the object type you are using in the class.h there are other ways to solve this also :- Look for class template instantiation. http://msdn2.microsoft.com/en-us/library/7y5ca42y.aspx[^]
Regards, FarPointer Blog:FARPOINTER