Develop a program in C++ to create a database of the following items of the derived class.
Name of the patient, sex, age, ward number, bed number, nature of illness, date of admission.
Design a base class consisting of data members : name of the patient, sex and age ; and another base class consisting of the data members : bed number and nature of the illness. The derived class consists of the data member ,date of admission.
Program should carry out the following methods
(i) Add a new entry.
(ii) List the complete record.
Name of the patient, sex, age, ward number, bed number, nature of illness, date of admission.
Design a base class consisting of data members : name of the patient, sex and age ; and another base class consisting of the data members : bed number and nature of the illness. The derived class consists of the data member ,date of admission.
Program should carry out the following methods
(i) Add a new entry.
(ii) List the complete record.
#include<conio.h>
#include<iostream.h>
class A
{
public:
char name[20];
char sex[10];
int age;
void get_data();
void disp_data();
};
void A::get_data()
{
cout<<"enter name:";
cin>>name;
cout<<"enter age:";
cin>>age;
cout<<"enter sex:";
cin>>sex;
}
void A::disp_data()
{
cout<<"name:"<<name<<'\n';
cout<<"age:"<<age<<'\n';
cout<<"sex:"<<sex<<'\n';
}
class B
{
public:
int bed_number;
char nature_illness[40];
void get_data();
void disp_data();
};
void B::get_data()
{
cout<<"enter bed number:";
cin>>bed_number;
cout<<"enter nature of illness:";
cin>>nature_illness;
}
void B::disp_data()
{
cout<<"bed number:"<<bed_number<<'\n';
cout<<"nature of illness:"<<nature_illness<<'\n';
}
class C:public A,public B
{
int date_admission;
public:
void get_data();
void disp_data();
void record();
};
void C::get_data()
{
A::get_data();
B::get_data();
cout<<"Enter Date of Admission:-> ";
cin>>date_admission;
}
void C::disp_data()
{
A::disp_data();
B::disp_data();
cout<<"Date of Admission :"<<date_admission;
}
void main()
{
clrscr();
C c1;
cout<<endl<<"Enter details to add a new record\n";
getch();
c1.get_data();
cout<<endl<<"Displaying the added record to database\n";
c1.disp_data();
getch();
}
#include<iostream.h>
class A
{
public:
char name[20];
char sex[10];
int age;
void get_data();
void disp_data();
};
void A::get_data()
{
cout<<"enter name:";
cin>>name;
cout<<"enter age:";
cin>>age;
cout<<"enter sex:";
cin>>sex;
}
void A::disp_data()
{
cout<<"name:"<<name<<'\n';
cout<<"age:"<<age<<'\n';
cout<<"sex:"<<sex<<'\n';
}
class B
{
public:
int bed_number;
char nature_illness[40];
void get_data();
void disp_data();
};
void B::get_data()
{
cout<<"enter bed number:";
cin>>bed_number;
cout<<"enter nature of illness:";
cin>>nature_illness;
}
void B::disp_data()
{
cout<<"bed number:"<<bed_number<<'\n';
cout<<"nature of illness:"<<nature_illness<<'\n';
}
class C:public A,public B
{
int date_admission;
public:
void get_data();
void disp_data();
void record();
};
void C::get_data()
{
A::get_data();
B::get_data();
cout<<"Enter Date of Admission:-> ";
cin>>date_admission;
}
void C::disp_data()
{
A::disp_data();
B::disp_data();
cout<<"Date of Admission :"<<date_admission;
}
void main()
{
clrscr();
C c1;
cout<<endl<<"Enter details to add a new record\n";
getch();
c1.get_data();
cout<<endl<<"Displaying the added record to database\n";
c1.disp_data();
getch();
}
You might also like:
No comments:
Post a Comment