I have this:
which works fine. But just for organizing better my code, I would like cmpItem do be inside the Item class. But then the code "items.sort(cmpItem)" doesn't compile, since cmpItem is probably at the wrong scope. Is there a way to do this?Code:
bool cmpItem (Item fst, Item snd) {
...
}
class Item {
...
};
class Character {
...
list<Item> items;
void addItem(Item item) {
...
items.sort(cmpItem);
}
};