0
我试图做出的boost :: ptr_vector和IM只是有一点麻烦的迭代工作容器类..构成容器类的boost :: ptr_vector
这里的成员之一功能IM试图实现:
//data is of type boost::ptr_vector<T>
//Date is a custom date class that i made with > operator overloaded
template <class T>
void P_VContainer<T>::addElementByDate(T* item)
{
boost::ptr_vector<T>::iterator it;
for(it = data.begin(); it < data.end(); it++)
{
T temp = *it;
Date = *lhs = item->getDate();
Date = *rhs = item.getDate();
if(*lhs > *rhs)
{
data.insert(it, item);
return;
}
}
data.insert(it, item);
}
我得到的错误是:
p_vcontainer.cpp: In member function ‘void P_VContainer<T>::addElementByDate(T*)’:
p_vcontainer.cpp:52:2: error: need ‘typename’ before ‘boost::ptr_vector<T>::iterator’ because ‘boost::ptr_vector<T>’ is a dependent scope
p_vcontainer.cpp:52:33: error: expected ‘;’ before ‘it’
p_vcontainer.cpp:54:7: error: ‘it’ was not declared in this scope
如何解决这个问题的任何想法?
感谢,有什么白痴.. heheh,如果你想不出告诉我刚学的模板: d – guskenny83