这里是我的代码:C++错误:迭代器是不是一个类型的“
template <typename container_type>
void transfer(container_type container, iterator begin, iterator end) {
for (; begin != end; begin++)
if (!element_in_container(container, *begin))
container.insert(iterator, *begin);
}
我得到的错误'iterator is not a type'
。
我试过在iterator
之前加std::
或container_type::
,没有帮助。我试着将模板定义为template <typename container_type<typename T> >
,迭代器为container_type<T>::iterator
,没有运气。怎么了?
'typename container_type :: iterator'? – 2014-10-12 10:50:37
确实,'iterator'不是一个类型。 – 2014-10-12 10:50:39
可能的重复:[我在哪里以及为什么必须放置“template”和“typename”关键字?](http://stackoverflow.com/questions/610245/where-and-why-do-i-have- to-put-the-template-and-typename-keywords) – 2014-10-12 10:53:13