I am trying to sort a list of Bike structures in a STL list, by passing my function into the sort parameter. I did it with integers, but can't figure out how to do it with strings, can anybody look at this and tell me how to fix it? Also, all of this is a header, the source file just implements main and the list of bike structures
header.sort(comp_id);
//This is what I did for the last one, but it looks like I need to use different syntax for the other version? I don't know
// this is what I did with my integer ones, and it worked fine
bool comp_id(const Bike & b1, const Bike & b2)
{
return b1.id_num < b2.id_num;
}
// THIS IS THE ONE I NEED TO FIGURE OUT
bool operator< (const Bike& b1, const Bike& b2)
{
return b1.manufact < b2.manufact;
}
//Here is the Structure that I am trying to sort by
struct Bike
{
char manufact[25];
int id_num;
status rented_code = NOT_RENTED; //RENTED/NOT_RENTED
char to_whom[25]; //to whom bike is rented
int size;
float cost_per_day;
bool deleted; //to mark bike as deleted in the list.
Bike* next_manuf; //pointer to next node in the
//manufacturers list
Bike* next_id; //pointer to the next node
//in the list by ID
Bike* next; //pointer to the next node in the general list
};
Aucun commentaire:
Enregistrer un commentaire