for some reason this code throws an error
// map<int, AnItem> roomlist;
// map<string, long> rinventory
map<int, AnItem>::iterator it;
for ( it = roomlist[roomno].rinventory.beg/in(); it != roomlist[roomno].rinventory.end(); it++ ) {
if( (*it).second.name == "Stock" )
tmpitem.append( strmug );
}
The if statment throws the error. It’s really not that complex and I would think I could handle this. So… roomlist is a map, roomno is an integer and rinventory is a map
class AnThing {
public:
AnThing(); // constructor
string name; // name reference
int gtid; // Thing ID
string lcname; // name in lowercase
string m_name;
};
class AnItem : public AnThing {
public:
ItemType m_type;
int imin;
int imax;
int ispeed;
long unsigned iprice;
unsigned int ecoin;
GAttributes m_attributes;
AnItem(); //Constructs an item with "invalid" values
int& Min(); // Returns the min attribute
int& Max(); // Returns the max attribute
int& Speed(); // Returns the speed attribute
};
Thanks in advance! I will append the errors I get below (there are two of them)
c:\ucdhb2\gaia\logonserver\v6\gaiaserver.cpp(812) : error C2679:
binary ‘=’ : no operator found which takes a right-hand operand of
type ‘std::_Tree<_Traits>::iterator’ (or there is no acceptable
conversion) 1> with 1> [ 1>
_Traits=std::_Tmap_traits,std::allocator>,false> 1> ] 1> c:\program
files\microsoft visual studio 9.0\vc\include\xtree(498): could be
‘std::_Tree<_Traits>::iterator
&std::_Tree<_Traits>::iterator::operator =(const
std::_Tree<_Traits>::iterator &)’ 1> with 1> [ 1>
_Traits=std::_Tmap_traits,std::allocator>,false> 1> ] 1> while trying to match the
argument list ‘(std::_Tree<_Traits>::iterator,
std::_Tree<_Traits>::iterator)’ 1> with 1> [ 1>
_Traits=std::_Tmap_traits,std::allocator>,false> 1> ] 1> and 1> [ 1>
_Traits=std::_Tmap_traits,std::allocator>,false> 1> ]
1>c:\ucdhb2\gaia\logonserver\v6\gaiaserver.cpp(812) : error C2678:
binary ‘!=’ : no operator found which takes a left-hand operand of
type ‘std::_Tree<_Traits>::iterator’ (or there is no acceptable
conversion) 1> with 1> [ 1>
_Traits=std::_Tmap_traits,std::allocator>,false> 1> ] 1> c:\program files\microsoft
sdks\windows\v6.0a\include\guiddef.h(197): could be ‘int operator
!=(const GUID &,const GUID &)’ 1> c:\program files\microsoft
visual studio 9.0\vc\include\xtree(314): or ‘bool
std::_Tree<_Traits>::const_iterator::operator !=(const
std::_Tree<_Traits>::const_iterator &) const’ 1> with 1>
[ 1>
_Traits=std::_Tmap_traits,std::allocator>,false> 1> ] 1> while trying to match the
argument list ‘(std::_Tree<_Traits>::iterator,
std::_Tree<_Traits>::iterator)’ 1> with 1> [ 1>
_Traits=std::_Tmap_traits,std::allocator>,false> 1> ] 1> and 1> [ 1>
_Traits=std::_Tmap_traits,std::allocator>,false> 1> ]
Your iterator
needs to be of type
based on your comment (i.e. you are iterating over
rinventory, notroomlist).