2010-09-06 62 views
1

我在上回为模板的方法的参数一些问题模板,看看:链接问题返回

// CTestClass.h 
template<class T> 
class CTestClass 
{ 
public: 
    T getNewValue(); 
}; 

// CTestClass.cpp 
template<class T> 
T CTestClass<T>::getNewValue() 
{ 
    return 10; // just for tests I'm returning hard coded 10 
} 

// main.cpp 
int _tmain(int argc, _TCHAR* argv[]) 
{ 
    CTestClass<int> s; 
    int a = s.getNewValue(); 
    return 0; 
} 

我得到了以下错误:

错误LNK2019:无法解析的外部符号“市民:INT __thiscall CTestClass ::的getNewValue(无效)”(?@的getNewValue $ CTestClass 3 H @@ QAEHXZ)函数引用_wmain

回答