There is a problem in the class method. It is necessary to rewrite the necessary class object from one list to another and delete it in one. But it is not fully working, I do not understand what the problem is.
Class Description:
class storage { // склад private: int size; provider provider; list <Medicine> medic; list <Medicine> sell_medic; public: storage(int size); void sell(); void show_storage(); void add(); void report(); ~storage(){ } }; Medecine Class Description:
class Medicine {//лекарство public: string name; float price; string group_medicine; Manufacturer manufacturer; Medicine() { } Medicine(string name, string group_medecine, float price, Manufacturer manufacturer); ~Medicine() { } }; Contents list:
Medicine("Ketorol Gel","Противовоспалительная Мазь", 62.7,Manufacturer("Dr.Reddy`s")), Medicine("Тизин","Капли для носа",43.15,Manufacturer("ФАРМАР ОРЛЕАН")), Medicine("Engystol","Противовирусное",205.1,Manufacturer("Хаймиттель")), Medicine("Stripsils intinsive","Противовоспальтельное",35.6,Manufacturer ("RIL")), Medicine("Уролесан","Противоспалительное",73.2,Manufacturer("ARTHERIUM")), Medicine("Цистон","Противовоспалительное",105.58,Manufacturer("Himalaya")), Medicine("Sinuforte","Спазморасширяющее",477.8,Manufacturer("Lab.Reig Jofre")), Description of the desired method:
void storage::sell() { string sell_name; cout << "\nВведите имя продаваемого товара" << endl; cin >> sell_name; copy_if(medic.begin(), medic.end(), back_inserter(sell_medic), [sell_name](const Medicine& med) { return med.name == sell_name; }); auto result = remove_if(medic.begin(), medic.end(), [sell_name](const Medicine& med) { return med.name == sell_name; }); medic.erase(result, medic.end()); }
==returns "not equal" where you expect equality. And because of what happens: the problem with the encoding, or you enter something wrong at all - we can't see from here. Try to start only Latin names. - AnT 3:53 pm