可能重複:
Where and why do I have to put the 「template」 and 「typename」 keywords?是否可以模板basic_string <> :: iterator?
進出口使用G ++ 4.6,我試圖根據所使用的字符類型到模板我的課,但我的變量的arent唯一的字符也是字符串那些字符。所以,我想是這樣的:
template<typename T>
class Node
//...
//constructor
Node(std::basic_string<T> str, std::basic_string<T>::iterator it)
{
}
//usage
Node<char16_t> start;
,但我得到 '的std :: basic_string的< _CharT,的std :: char_traits < _CharT>的std ::分配器< _Tp1>> ::迭代' 不是一個類型
當我將構造函數arg列表中的第二個T替換爲char16_t時,它將進行編譯。
使'typename std :: basic_string :: iterator it'。 –
ildjarn
2012-03-01 23:57:57