Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
#include<iostream>
using namespace std;
class Hospital_Database //The class
{
    protected: // Access specifier
             string Patient_Name; //Strings are used for storing text.
             string Date_of_Admission;
             string Disease;
             string Date_of_Relaease;
             string Age;
             string Sex;
    public: // Access specifier
    void GetData() //function defined inside the class


What I have tried:

why i use getData()
Posted
Updated 8-Aug-22 9:21am

Without any idea what it does, we have to guess. But the name implies that you should write it to fill in the variables defined above it from whatever data source you are using.
For example, in a COnsole app, you might create an instance of the class, then call GetData to prompt the user to enter the patient Name, admission date, Release date, Disease, and so on. Your function then stores those responses in the variables so they are part of that instance of a patient.

But to be honest, there is some screwy naming going on there: a whole database will not normally contain info on just one patient ...
 
Share this answer
 
The answer is quite clearly shown in your previous question on this subject at Explain following class, access modifire, inharitance, polimorphizom, function and veriables[^].
 
Share this answer
 
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
C++
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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900