【发布时间】:2023-03-13 21:01:02
【问题描述】:
这有点难以解释,但基本上,我想做这样的事情:
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> int some<T>::hello(){ ... -
@πάνταῥεῖ 你知道这是否有骗局吗?感觉应该有,但是我只能找到成员模板的外行定义。
-
@πάνταῥεῖ 啊,完美,谢谢:)