lot of questions like this are there but i tried most of them but i couldn't success. as my last try i came up without any errors but the function does not work
this is what i did last i need to remove the specific object from list
void discharge_patients() {
string str;
cout << "Enter Patients Name : " << endl;
cin >> str;
for (hospital const& common : hospitalList) {
if(common.getPatientName() == str){
cout << "\nPatient Name : " << common.getPatientName() << "\t";
hospitalList.remove(common);
break;
}
}
iputData();
}
declaration of hospitalList
list<hospital> hospitalList;
this is how i add objects to hospitalList
void admit_patient() {
hospital obj;
string str;
int val;
cout << "Enter Patients Name : " << endl;
cin >> str;
obj.setPatientName(str);
cout << "Enter Bed Number : " << endl;
cin >> val;
obj.setBedNum(val);
cout << "Enter Date of Admit 'dd/mm/yyyy' : " << endl;
cin >> str;
obj.setDateOfAdmit(str);
cout << "Enter Patient Age :" << endl;
cin >> val;
obj.setAge(val);
cout << "Enter Patient Ward No :" << endl;
cin >> val;
obj.setWardNumber(val);
//push the object to hospitalList
hospitalList.push_back(obj);
iputData();
}
this is how my hospital
class looks like
class hospital {
public: string Patient_Name, Date_of_Admit; int Bed_Num, Age, Ward_Number;
int getAge() const {
return Age;
}
void setAge(int age) {
Age = age;
}
int getBedNum() const {
return Bed_Num;
}
void setBedNum(int bedNum) {
Bed_Num = bedNum;
}
const string& getPatientName() const {
return Patient_Name;
}
void setPatientName(const string& patientName) {
Patient_Name = patientName;
}
int getWardNumber() const {
return Ward_Number;
}
void setWardNumber(int wardNumber) {
Ward_Number = wardNumber;
}
const string& getDateOfAdmit() const {
return Date_of_Admit;
}
void setDateOfAdmit(const string& dateOfAdmit) {
Date_of_Admit = dateOfAdmit;
}
};