[英]error: no match for operator=in C++
Hi I'm getting this error when compiling with g++ 4.1.2 嗨,我在使用g ++ 4.1.2编译时遇到此错误
"error: no match for operator= in" ((PoolElementList*)this)->PoolElementList::i_currentElement = ((PoolElementList*)this)->PoolElementList::i_elementList.std::vector<_Tp, _Alloc>::end with _Tp = ModifyTerminationPointReqInfo*, _Alloc = std::allocator “错误:操作符=中不匹配”(((PoolElementList *)this)-> PoolElementList :: i_currentElement =((PoolElementList *)this)-> PoolElementList :: i_elementList.std :: vector <_Tp,_Alloc> :: end与_Tp = ModifyTerminationPointReqInfo *,_Alloc = std :: allocator
Definition of PoolElements is as follows: PoolElements的定义如下:
template <class Element, Element *intialElementPtr>
class PoolElementList
{
GenericMemoryPool <Element, intialElementPtr> *i_elementPoolPtr;
vector <Element *> i_elementList;
vector <Element *> i_currentElement;
public:
//Define a constructor that takes in a pointer of the pool.
PoolElementList(GenericMemoryPool <Element, intialElementPtr> *elementPool):
i_elementPoolPtr (elementPool)
{
i_currentElement = i_elementList.end(); //error is here**
};
Please someone can explain what could be wrong in this. 请有人可以解释这可能出什么问题。 (This was compiling in g++ 2.9.x) (这是在g ++ 2.9.x中编译的)
If (as you said in your comment) you intend for i_currentElement
to be a std::vector<Element *>::iterator
, then you must declare it as one. 如果(如您在评论中所说)希望i_currentElement
成为std::vector<Element *>::iterator
,则必须将其声明为一个。 Simply replace 只需更换
vector <Element *> i_elementList;
with 与
vector <Element *>::iterator i_elementList;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.