Original Post
I want to sort my std::list by priority. If I std::sort it it will sort by address so I'm trying to ovvreride this however possible. I tried three ways and they all didnt work.
class System{
public:
int priority;
bool operator<(const System& system) const
{return (priority < system.priority)?true:false;}
}; ************************* inline bool operator<(const System* a, const System* b) const
{ return ((*a) < (*b)); }
systems.sort(); error C2270: '<' : modifiers not allowed on nonmember functions error C2803: 'operator <' must have at least one formal parameter of class type ************************* inline bool System_sort_1(const System* a, const System* b) const
{ return (*a < *b); }
systems.sort(System_sort_1); error C2270: 'System_sort_1' : modifiers not allowed on nonmember functions ************************* struct System_sort_2 : public std::binary_function < const System* const, const System* const, bool >
{
bool operator()(const System* const a, const System* const b) const
{ return (*a < *b); }
};
systems.sort(System_sort_2);
error C2275: 'System_sort_2' : illegal use of this type as an expression What gives?