2011-08-07 42 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:完全沒問題。 :) –