Tuesday, 20 March 2018

Multipath Inheritance

//Multipath Inheritance
#include<iostream.h>
#include<conio.h>
class a
{
 protected:
 int id;
};
class b:virtual public a
{
 protected:
 char name[30];
};
class c:virtual public a
{
 protected:
 char city[30];
};
class d:public b,c
{
 protected:
 char game[20];
 public:
 void getdata()
 {
  cout<<"\n Enter the following information ";
  cout<<"\n ID : ";cin>>id;
  cout<<"\n Name : ";cin>>name;
  cout<<"\n City : ";cin>>city;
  cout<<"\n Game : ";cin>>game;
 }
 void display()
 {
  cout<<"\n Entered information is ";
  cout<<"\n ID : "<<id;
  cout<<"\n Name : "<<name;
  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.