2011-08-07 40 views
21

我无法声明模板类。我尝试了一些不可读和非感性的组合。'X不是模板'错误

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

而且

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; 
}; 

回答

37

这是它说什么。

您的模板参数列表显示M is a class, not a template

如果你说这是一类模板then everything's fine

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

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

+0

非常感谢!我想我确实拥有它,但我让CPP文件中的错误让我分心。 – jww

+0

@noloader:完全没问题。 :) –