在模板外定义函数模板 class
define function templated class outside of template
有点难以解释,但基本上,我想做这样的事情:
template <typename T>
class some{
int hello();
};
//The method needs to be defined outside of the template class declaration and be able to use T defined in the template
int some::hello(){
T* other = new T;
T->doSomething();
}
我该怎么做?
给你:
template <typename T>
class some{
int hello();
};
//The method needs to be defined outside of the template class declaration and be able to use T defined in the template
template<typename T>
int some<T>::hello(){
T* other = new T;
other->doSomething();
}
有点难以解释,但基本上,我想做这样的事情:
template <typename T>
class some{
int hello();
};
//The method needs to be defined outside of the template class declaration and be able to use T defined in the template
int some::hello(){
T* other = new T;
T->doSomething();
}
我该怎么做?
给你:
template <typename T>
class some{
int hello();
};
//The method needs to be defined outside of the template class declaration and be able to use T defined in the template
template<typename T>
int some<T>::hello(){
T* other = new T;
other->doSomething();
}