no match for operator= using a std::vector
Posted
by Max
on Stack Overflow
See other posts from Stack Overflow
or by Max
Published on 2010-06-14T23:40:43Z
Indexed on
2010/06/14
23:42 UTC
Read the original article
Hit count: 370
I've got a class declared like this:
class Level
{
private:
std::vector<mapObject::MapObject> features;
(...)
};
and in one of its member functions I try to iterate through that vector like this:
vector<mapObject::MapObject::iterator it;
for(it=features.begin(); it<features.end(); it++)
{
/* loop code */
}
This seems straightforward to me, but g++ gives me this error:
src/Level.cpp:402: error: no match for ‘operator=’ in ‘it = ((const yarl::level::Level*)this)->yarl::level::Level::features.std::vector<_Tp, _Alloc>::begin [with _Tp = yarl::mapObject::MapObject, _Alloc =
std::allocator<yarl::mapObject::MapObject>]()’
/usr/include/c++/4.4/bits/stl_iterator.h:669: note: candidates are: __gnu_cxx::__normal_iterator<yarl::mapObject::MapObject*,
std::vector > >& __gnu_cxx::__normal_iterator<yarl::mapObject::MapObject*,
std::vector > >::operator=(const __gnu_cxx::__normal_iterator<yarl::mapObject::MapObject*, ``std::vector<yarl::mapObject::MapObject, std::allocator<yarl::mapObject::MapObject> > >&)
Anyone know why this is happening?
© Stack Overflow or respective owner