Quote:
Why I use getdata() in this code
We ask ourselves the same question.
As Richard has already noted, you are already using the method here:
https://www.codeproject.com/Questions/5339199/Explain-following-class-access-modifire-inharitanc
class Hospital_Database
{
protected:
string Patient_Name;
string Date_of_Admission;
string Disease;
string Date_of_Relaease;
public:
void GetData();
...
}
void Hospital_Database::GetData()
{
cout<<"Enter Details of Patient: "<<endl <<endl;
cout<<"Enter Patient Name: ";
cin>>Patient_Name;
cout<<"Enter Date of Admission: ";
cin>>Date_of_Admission;
cout<<"Enter Disease of Patient: ";
cin>>Disease;
cout<<"Enter Date of Release: ";
cin>>Date_of_Relaease;
}
And OriginalGriff has already stated that a hospital database with data from only one patient makes little sense.
Moreover, the method as it is already implemented is not very practical, since the information that is queried is certainly not all known at the beginning. The patient name and the date of admission could be known at the beginning. With the illness it becomes already more difficult, it is perhaps not yet certain and is diagnosed perhaps only later by a physician. To be able to predict the date of discharge, one would need a clairvoyant or one would have to guess. It should also be possible to change both the diagnosis and the discharge date.