сортировку по алфавиту с++
необходимо сделать сортировку по алфавиту, 10 номер, сколько не пытаюсь выдает ошибку, врубиться не могу :(
main.cpp: In function ‘int main()’:
main.cpp:212:52: error: no match for ‘operator==’ (operand types are ‘int’ and ‘const std::__cxx11::basic_string’)
212 | while (in >> tos) if (tos.category == it->first && tos.title == it->second && tos.category <= n) { cout << tos << " "; break; }
| ~~~~~~~~~~~~ ^~ ~~~~~~~~~
| | |
| int const std::__cxx11::basic_string<char>
Объявление типа для переменной, участвующей в сравнении:
struct Toys {
string title;
float price;
int amount;
int category;
int manufacturercode;
friend ostream& operator << (ostream& out, const Toys& a_o) {
out << a_o.title << ' ' << a_o.price << ' ' << a_o.amount << ' ' << a_o.category << ' ' << a_o.manufacturercode << ' ' << endl;
return out;
}
friend istream& operator >> (istream& in, Toys& a_o) {
in >> a_o.title >> a_o.price >> a_o.amount >> a_o.category >> a_o.manufacturercode;
return in;
}
};
Фрагмент кода с ошибкой:
multiset<pair<string, float>> un;
Toys tos; Manufacturer mnf;
Toys minA, maxA;
for (auto it = un.begin(); it != un.end(); it++) {
in.open(tys);
while (in >> tos) if (tos.category == it->first && tos.title == it->second && tos.category <= n) { cout << tos << ; break; }
in.close();
}
Источник: Stack Overflow на русском