Tuesday, 20 March 2018

Hybrid Inheritance

//Hybrid inheritance
#include<iostream.h>
#include<conio.h>
class a
{
 protected:
 int id;
 char name[30];
};
class b:public a
{
 protected:
 float height;
 float weight;
};
class c
{
 protected:
 char city[30];
};
class d: public b,c
{
 protected:
 char game[30];
 public:
 void getdata()
 {
  cout<<"\n Enter Following Information is \n";
  cout<<"\n ID : ";cin>>id;
  cout<<"\n Name : ";cin>>name;
  cout<<"\n Height : ";cin>>height;
  cout<<"\n Weight : ";cin>>weight;
  cout<<"\n City : ";cin>>city;
  cout<<"\n Game : ";cin>>game;
 }
 void display()
 {
  cout<<"\n Entered Information is \n";
  cout<<"\n ID : "<<id;
  cout<<"\n Name : "<<name;
  cout<<"\n Height : "<<height;
  cout<<"\n Weight : "<<weight;
  cout<<"\n City : "<<city;
  cout<<"\n Game : "<<game;
 }
};
void main()
{
 clrscr();
  d obj;
  obj.getdata();
  obj.display();
 getch();
}

No comments:

Post a Comment

Note: only a member of this blog may post a comment.