简体   繁体   中英

error: no match for operator=in C++

Hi I'm getting this error when compiling with 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

Definition of PoolElements is as follows:

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)

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. Simply replace

vector <Element *> i_elementList;

with

vector <Element *>::iterator i_elementList;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM