I got a struct that a user can define what string values go in where. I've tried ordering it alphabetically but had no luck with what research I found online. I was hoping if one of use can see where im going wrong
libraries being used : iostream, string, fstream and algorithm
struct House
{
int room_num;
string person;
};
struct compare_by_word
{
bool operator()(const House& lhs, const House& rhs)
{
return lhs.person < rhs.person;
}
};
I get errors on this line, by the way im using visual studios 2010
void asc_order()
{
sort(data.begin(), data.end(), compare_by_word());
//for loop will be displayed here to show table
}
Errors I get:
Error: Identifier data is undefined
struct compare_by_word Error: type name is not allowed
vector<House> data;in your code somewhere in sideasc_orderbefore callingsort. Hopefully filling it with some Houses.