23.4 Sets (cont.)

2 ways to form sets of a new object type. Using the Employee class for our example.

  1. Override operator<, allowing the normal declaration:
    bool operator< (const Employee& a, const Employee& b)
    {
       return a.salary() < b.salary();
    }
    
    set<Employee> workers; // Will be sorted by salary

prev |top |next