나는 템플릿 메소드를 만들 수 있음을 읽었습니다. Student.h템플릿 호출 방법
class Student
{
public:
template<class typeB>
void PrintGrades();
};
파일 : 나는 내 코드에
파일 같은 것을 가지고
Student st;
st.PrintGrades<std::string>();
이제 MAIN.CPP 지금 Student.cpp
#include "Student.h"
#include <iostream>
template<class typeB>
void Student::PrintGrades()
{
typeB s= "This is string";
std::cout << s;
}
를 I 링커 가져 오기 오류 :
Error 1 error LNK2019: unresolved external symbol "public: void __thiscall Student::PrintGrades<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >(void)" ([email protected][email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@@[email protected]@QAEXXZ) referenced in function _main
내가 뭘 잘못하고 있을지에 대한 제안이 있으십니까?
나는이 중복 방법을 볼니까. 그 게시물은 템플릿 클래스가 아니라 템플릿 클래스에 대해 이야기합니다. – MistyD
동일하게 적용됩니다. – juanchopanza