Implementation of Multiple Inheritance

//TOPIC:USE OF MULTIPLE INHERITANCE
//AIM: CREATE A DERIVED CLASS FROM TWO BASE CLASSES


#include<iostream.h>
#include<conio.h>
class book_title
{public:
char aut[20];
char title[10];
void get()
{cout<<"Enter title of book & author of book:\n";
cin>>title>>aut;
}
void display()
{cout<<"\nTitle of book: "<<title;
cout<<"\nAuthor: "<<aut;


}};
class book_info
{public:
int page,price;
void get1()
{cout<<"Enter  total pages and price of book\n";
cin>>page;
cin>>price;
}void display1()
{
cout<<"\nTotal pages:"<<page<<"\nPrice:Rs."<<price;
}
};
class book:public book_title,public book_info
{int acc_no;
public:
void get2()
{cout<<"Enter accession no: ";
cin>>acc_no;
}
void display2()
{cout<<"\nAccession no. of book: "<<acc_no;
}};
void main()
{book obj;
clrscr();
cout<<"\n\n---GIVE DETAILS OF BOOK---\n\n";
obj.get2();
obj.get();
obj.get1();
cout<<"\n\n---INFORMATION OF BOOK---\n";
obj.display2();
obj.display();
obj.display1();


getch();
}
Previous
Next Post »