Below is my C++ program which is divided into 2 .h files and 1 .cpp file. I need you to fix one error that I am getting in the append function. I am trying to call that function in main but I can't think of what argument to pass in that function. I know why I'm getting that error but can't fix it. So, please fix the error and provide the fixed code in your answer. You can make changes in the append function or the inputPatients function and also make changes in the main program if that helps you fix the error. Just fix this error and provide me the code. THANKS !!!
//node.h
#pragma once #include using namespace std; class node { public: int data; node* next; };
// list.h
#pragma once #include"node.h" #include #include using namespace std; class list { private: node *head; string name, city, symptoms, immune_level, severity; int admit_no, age; public: list() { this->head = NULL; } bool append(int data) { node* temp = new node; temp->data = data; temp->next = NULL; if (head == NULL) { head = temp; return true; } node* last = head; while (last->next != NULL) { last = last->next; } last->next = temp; cout << "Append completed" << endl; return true; } void update(string data, string newData) { node *temp = new node; while (head != NULL) { if (name == data) { name = newData; break; } head = head->next; } } int listLength(node* head) { int temp = 0; if (head == NULL) { cout << "Node is empty" << endl; return 0; } while (head->next != NULL) { ++temp; head = head->next; } return temp + 1; } void deletee(node* head, int loc) { node* temp = new node; temp = head; if (head == NULL) { cout << "Node is null" << endl; return; } for (int i = 1; i <= loc; ++i) { temp = temp->next; if (i < loc) { head = head->next; } } head->next = temp->next; } node* search(node* head, string v) { if (head == NULL) { cout << "Node is empty returning null" << endl; return NULL; } int l = 1; while (head->next != NULL && name != v) { head = head->next; ++l; } cout << "Element found at location " << l << endl; return head; } void check(list d) { if (d.immune_level == "low" && d.symptoms == "fever" || d.symptoms == "dry cough" || d.symptoms == "tiredness") { cout << d.name << " is a corona virus patient. "; } else { cout << d.name << " is not a corona virus patient. "; } } void printLinkedList(node* head) { if (head == NULL) { cout << "Head is null" << endl; return; } while (head->next != NULL) { cout << "Name: " << name << ", City: " << city << ", Immune Level: " << immune_level << ", Symptoms: " << symptoms << ", Severity: " << severity << ", Age: " << age << ", Admit No: " << admit_no << endl; head = head->next; } cout << "Name: " << name << ", City: " << city << ", Immune Level: " << immune_level << ", Symptoms: " << symptoms << ", Severity: " << severity << ", Age: " << age << ", Admit No: " << admit_no << endl; } list inputPatients() { string name, city, symptoms, immune_level, severity; int admit_no, age; list p; cout << "Enter Patient Name: "; cin.ignore(); getline(cin, name); cout << "Enter Patient City: "; getline(cin, city); cout << "Enter Patient Symptoms: "; getline(cin, symptoms); cout << "Enter Patient Immune Level: "; getline(cin, immune_level); cout << "Enter patient Severity: "; getline(cin, severity); cout << "Enter Patient Admit No.: "; cin >> admit_no; cout << "Enter Patient Age: "; cin >> age; p.name = name; p.city = city; p.symptoms = symptoms; p.immune_level = immune_level; p.severity = severity; p.admit_no = admit_no; p.age = age; cout << "Completed input operation" << endl; return p; } bool authenticateUser() { string username, password; cout << "Enter Username: "; getline(cin, username); cout << "Enter Password: "; getline(cin, password); if (username.compare("admin") == 0 && password.compare("pass123") == 0) { return true; } return false; } };
// main.cpp
#include"list.h" int main() { node* head = NULL; list l; string nameToSearch; string oldName, newName; while (!l.authenticateUser()) { cout << "Failed. Wrong username or password. Try again!! "; } cout << "Login successful!! "; int op; cout << " 1-Add Patient 2-Delete Patient(Must have 3 patients in hospital to delete patients.) 3-Search by Name 4-Total Patients in Hospital 5-Print All Patients Record 6-Update Patient Name 7-Save Records in a file 8-Exit" << endl; while (cin >> op) { switch (op) { case 1: cout << "Enter Patient Details Below" << endl; l.inputPatients(); l.append(); break; case 2: if (l.listLength(head) < 2) { cout << "Length is less then two. Terminating program" << endl; exit(1); } else { cout << "Enter location where you want to delete a patient"; int a; cin >> a; l.deletee(head, a - 1); } break; default: cout << "Wrong option Selected" << endl; } cout << " 1-Add Patient 2-Delete Patient(Must have 3 patients in hospital to delete patients.) 3-Search by Name 4-Total Patients in Hospital 5-Print All Patients Record 6-Update Patient Name 7-Save Records in a file 8-Exit" << endl; } }