INHERITANCE USING C++



/*HOSPITAL MANAGEMENT USING INHERITANCE*/

PROGRAM: 
#include<iostream.h>
#include<conio.h>
class hospital
{
 private:
            char doc[20];
            int rno,pho;
 public:
            void getdata();
            void display();
}h;
class patient
{
 private:
            char name[20],dis[25],add[20];
            int phno,rno;
 public:
            void getdata();
            void display();
}p;
class details:public hospital,public patient
{
 public:
            void getdata();
            void display();
}d;
void hospital::getdata()
{
 cout<<"\n Enter doctor name:";
 cin>>doc;
 cout<<"\n Enter doctor room no:";
 cin>>rno;
 cout<<"\n Enter doctor phone no:";
 cin>>pho;
}
void patient::getdata()
{
 cout<<"\n Enter patient name:";
 cin>>name;
 cout<<"\n Enter patient address:";
 cin>>add;
 cout<<"\n Enter Room no :";
 cin>>rno;
 cout<<"\n Enter patient diseases:";
 cin>>dis;
 cout<<"\n Enter phone no:";
 cin>>phno;
}
void hospital::display()
{
 cout<<"\n Doctor name       :"<<doc<<endl;
 cout<<"\n Doctor Roomno     :"<<rno<<endl;
 cout<<"\n Doctor phone no   :"<<pho<<endl;
}

void patient::display()
{
 cout<<"\n Patient name    :"<<name<<endl;
 cout<<"\n Roomno          :"<<rno<<endl;
 cout<<"\n Diseases        :"<<dis<<endl;
 cout<<"\n Patient phone no:"<<phno<<endl;
}
void details::getdata()
{
 hospital::getdata();
 patient::getdata();
}
void details::display()
{
 patient::display();
 hospital::display();
}
void main()
{
 clrscr();
 cout<<"\n\t HOSPITAL MANAGEMENT USING INHERITANCE";
 cout<<"\n\t ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n";
 cout<<"\n Enter the details";
 d.getdata();
 cout<<"\n Patient details";
 d.display();
 getch();
}

 OUTPUT:


         HOSPITAL MANAGEMENT USING INHERITANCE
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

 Enter the details

 Enter doctor name:VINOTH

 Enter doctor room no:20

 Enter doctor phone no:245678

 Enter patient name:VIVEK

 Enter patient address:KARUMATHAMPATTI, CBE

 Enter Room no :201

 Enter patient diseases:FEVER

 Enter phone no:2598020


 Patient details

 Patient name               :VIVEK

 Roomno                      :201

 Diseases                     :FEVER

 Patient phone no        :2598020

 Doctor name              :VINOTH

 Doctor Roomno         :20

 Doctor phone no        :245678


Comments

Popular posts from this blog

TRAVELING SALESMAN USING BRANCH AND BOUND TECHNIQUE

BOOKS DETAILS USING C STRUCTURE

TRAVELING SALESMAN USING BRANCH AND BOUND TECHNIQUE