【问题标题】:What is wrong with function returning typename list<T>::iterator? [duplicate]返回 typename list<T>::iterator 的函数有什么问题? [复制]
【发布时间】:2012-07-02 10:49:04
【问题描述】:

可能重复:
Where and why do I have to put the “template” and “typename” keywords?

我写过:

template<class T> 
typename list<T>::iterator partition(list<T> &, list<T>::iterator, list<T>::iterator);

但是我的编译器发现了一个错误:

错误:'std::list::iterator' 不是类型

这个函数有什么问题?

【问题讨论】:

  • 非常感谢,Xeo!现在我知道了 - 我刚刚忘记了参数中“list...”之前的“typename”字样。

标签: c++ list templates stl iterator


【解决方案1】:

试试:

 template<class T> 
 typename list<T>::iterator partition(list<T> &, typename list<T>::iterator, typename list<T>::iterator);
                                                 ^^^^^^^^                    ^^^^^^^^

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-05-30
    • 2011-07-03
    • 1970-01-01
    • 2020-09-15
    • 1970-01-01
    • 2020-08-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多