I'm having trouble with using a multiset of my own data structure. It seems to complain about my comparison (less than) function when I try to iterate, but it works at some level because I can insert() stuff and call functions from the first member of the multiset. If anyone can point me in the right direction of solving my problem I'd appreciate it.
struct sprites {
unsigned int x_coord;
unsigned int y_coord;
short int animation;
sprites(unsigned int, unsigned int, short int);
void draw(void) const;
bool operator< (const sprites& cmpParam) const;
};
bool sprites::operator< (const sprites& cmpParam) const {
return(x_coord < cmpParam.x_coord);
}
in the main code:
for(multiset<sprites>::iterator iter=fg_sprites.begin(); iter<fg_sprites.end(); iter++) iter->draw(); //does not work
fg_sprites.begin()->draw(); // works