저는 현재 C++에 대한 심도있는 학습을하고 있으며 몇 시간 동안 저조한 것을 발견했습니다. 템플릿을 만든 다음 특수화 할 때 특수 버전에 해당 함수를 호출하거나 정의 할 수없는 이유는 무엇입니까? 컴파일러가 불평하고, 내가 뭘 잘못하고 있는지에 대한 힌트를 얻으려고 구글을 샅샅이 뒤졌지만 아무 소용이 없다. 나는 내가 내려다 오전 아주 간단한 것을 매우 확신 :특수 템플릿의 C++ 함수 정의 및 호출
template <typename T>
class C { };
//specialization to type char
template <>
class C <char>
{
public:
void echo();
};
//compiler complains here
template <>
void C <char> :: echo()
{
cout << "HERE" << endl;
}
error: template-id ‘echo<>’ for ‘void C::echo()’ does not match any template declaration
Demo.
[template-id가 템플릿 delcaration과 일치하지 않음] (http://stackoverflow.com/questions/4694181/template-id-does-not-match-any-template-delcaration) – GWW