WELCOME

Welcome to KoDes4U

Pages

Wednesday, March 9, 2011

Inheritence(C++ program)

/*Design a base class with name , date of birth, blood group another base
class consisting of the data members such as height and weight. Design one
more base class conisting of the insurance policy number and contact address.
The derived class contains the data members telephone numbers and driving
lisence number. Coded for KoDes4U.blogspot.com*/


#include
#include

#include

class base1
{
public:
char name[50],date_of_birth[10],blood_group[3];
};
class base2
{
public:
int no;
char height[5],weight[5];
};
class base3
{
public:
char in_pol_no[10],cont_add[15];
};
class d:public base1,public base2,public base3
{
char ph_no[10],drvng_lic_no[10];
public:
void get_data()
{
cout<<"\nEnter number : "; cin>>no;
cout<<"\nEnter name : "; cin>>name;
cout<<"\nEnter date of birth : "; cin>>date_of_birth;
cout<<"\nEnter blood group : "; cin>>blood_group;
cout<<"\nenter height(in cms) : "; cin>>height;
cout<<"\nEnter weight(in kgs) : "; cin>>weight;
cout<<"\nEnter insurance policy no : "; cin>>in_pol_no;
cout<<"\nEnter contact address : "; cin>>cont_add;
cout<<"\nEnter phone number(please include STD code) : "; cin>>ph_no;
cout<<"\nEnter driving licence number : "; cin>>drvng_lic_no;
}
void disp_info()
{
cout<<"\nSerial no : "<
>ch;
switch(ch)
{
case 1:
cout<<"\nEnter no.of records : "; cin>>x;
for(i=0;i
>j;
for(i=0;i
>j;
for(i=0;i
obj[i].search(obj[i].no,j);
cout<<"\nResult : ";
obj[j-1].disp_info();
break;
}
}while(ch!=7);
file.close();
}

No comments:

Post a Comment