当我尝试编译这个时,我得到了这个错误:
error: expected `;' before 'it'
为什么我不能声明这个迭代器?问题出在哪里?
#include <list>
template <typename Z>
class LBFuncBase: public LBBaseBlock<Z>
{
void Something() {
std::list<LBBaseBlock< Z >* >::iterator it;
}
};
最佳答案
尝试:
typename std::list<LBBaseBlock< Z >* >::iterator it;
编辑:
有关解释,请参阅“Why do you sometimes need to write typename”。
关于c++ - 无法使用模板编译 std::list 迭代器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1911162/