テンプレートメソッドを作成できることを読みました。コードにこのようなものがあります
ファイル : Student.h
class Student
{
public:
template<class typeB>
void PrintGrades();
};
ファイル: Student.cpp
#include "Student.h"
#include <iostream>
template<class typeB>
void Student::PrintGrades()
{
typeB s= "This is string";
std::cout << s;
}
今main.cppにあります
Student st;
st.PrintGrades<std::string>();
今、私はリンカーエラーを受け取ります:
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)" (??$PrintGrades@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Student@@QAEXXZ) referenced in function _main
私が間違っているかもしれないことについて何か提案はありますか?