0

嗨,我在使用 g++ 4.1.2 编译时遇到此错误

“错误:operator= in 不匹配” ((PoolElementList*)this)->PoolElementList::i_currentElement = ((PoolElementList*)this)->PoolElementList::i_elementList.std::vector<_Tp, _Alloc>::end _Tp = ModifyTerminationPointReqInfo*, _Alloc = std::allocator

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**
        };

请有人可以解释这可能有什么问题。(这是在 g++ 2.9.x 中编译的)

4

1 回答 1

0

如果(正如您在评论中所说)您打算i_currentElement成为 a std::vector<Element *>::iterator,那么您必须将其声明为 one。只需更换

vector <Element *> i_elementList;

vector <Element *>::iterator i_elementList;
于 2012-11-29T06:07:01.053 回答