Featured Post

Step Wise Project Planning

Planning is the most difficult process in project management. The framework described is called the Stepwise method to help to distinguis...

  1. Home

A hospital wants to create a database regarding its indoor patients. The information to store include :- Name of the patient, Date of admission, Disease, Date of discharge.Create a structure to store the date (year, month and date as its members). Create a base class to store the above information. The member function should include functions to enter information and display a list of all the patients in the database. Create a derived class to store the age or the patients. List the information about all the to store the age of the patients. List the information about an the pediatric patients (less than twelve years in age).

#include<iostream.h>
struct date
{
int d;
int m;
int y;
};
class hospital
{
char name[100];
struct date d_adm;
struct date d_dis;
public:
void getdata()
{
cout<<"Enter name of the patient: ";
cin>>name;
cout<<"Enter date of admission: ";
cin>>d_adm.d>>d_adm.m>>d_adm.y;
cout<<"Enter date of discharge: ";
cin>>d_dis.d>>d_dis.m>>d_dis.y;
}
void display()
{
cout<<"Patient name: "<<name;
cout<<"Date of admission: "<<d_adm.d<<d_adm.m<<d_adm.y;
cout<<"Date of discharge: "<<d_dis.d<<d_dis.m<<d_dis.y;
}};
class age:public hospital
{
int a;
public:
void get()
{
cout<<"Enter age: ";
cin>>a;
}
void put()
{
if(a<12)
{
display();
cout<<"age: "<<a;
}
else
cout<<"age greater than 12";
}};
int main()
{
age a1;
a1.getdata();
a1.get();
a1.put();
return 0;
}
  


Output


Previous
Next Post »