Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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;
};
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
170 views
Welcome To Ask or Share your Answers For Others

1 Answer

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).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...