模板类中模板方法的声明模板定义 [英] Out of declaration template definitions for template method in template class

查看:102
本文介绍了模板类中模板方法的声明模板定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有人知道模板类中声明外模板方法的语法。

Does anyone know the syntax for an out-of-declaration template method in a template class.

例如:

template<class TYPE>
class thing
{
public :
  void do_very_little();

  template<class INNER_TYPE>
  INNER_TYPE do_stuff();
};

第一种方法定义为:

template<class TYPE>
void thing<TYPE>::do_very_little()
{
}

我如何做第二个do_stuff?

How do I do the second one, "do_stuff"?

推荐答案

template<class TYPE>
template<class INNER_TYPE>
INNER_TYPE thing<TYPE>::do_stuff()
{
    return INNER_TYPE();
}

查看此页:

http://msdn.microsoft.com/en-us/library/ swta9c6e(VS.80).aspx

这篇关于模板类中模板方法的声明模板定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆