'X不是模板'错误 [英] 'X is not a template' error

查看:152
本文介绍了'X不是模板'错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法声明模板类。

 模板< class C,class M> 
class BlockCipherGenerator:public KeyGenerator
{
...
private:
M< C> m_cipher;
};



 模板< class C,class M> 
class BlockCipherGenerator:public KeyGenerator
{
typedef typename C :: value_type CIPHER;
typedef typename M :: value_type MODE;
私人:
模式< CIPHER> m_cipher;
};


解决方案

这就是它说的。



您的模板参数列表显示 M ,而不是模板

如果您说它是一个类模板,那么然后一切正常: p>

 模板< class C,template< class C>班级M> 
class BlockCipherGenerator:public KeyGenerator
{
M< C> m_cipher;
};






请记住, std :: vector 不是类,而是类模板。像 std :: vector< int> 是一个类(类型)。


I'm having trouble declaring a template class. I've tried an number of ill-readable and non-sensical combinations.

template <class C, class M >
class BlockCipherGenerator : public KeyGenerator
{
  ...
  private:
      M < C > m_cipher;
};

And

template <class C, class M >
class BlockCipherGenerator : public KeyGenerator
{
  typedef typename C::value_type CIPHER;
  typedef typename M::value_type MODE;
  private:
      MODE < CIPHER > m_cipher;
};

解决方案

It's what it says.

Your template parameter list says that M is a class, not a template.

If you say that it's a class template, then everything's fine:

template <class C, template <class C> class M>
class BlockCipherGenerator : public KeyGenerator
{
      M<C> m_cipher;
};


Remember, something like std::vector is not a class, but a class template. Something like std::vector<int> is a class (type).

这篇关于'X不是模板'错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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