Sunday, January 1, 2012

Multiple inheritence in 'C++'

Example



#include<iostream.h>
#include<conio.h>
class stud
{
protected:
char nm[10],add[20],city[10],rno[10];
public:
void getdata()
{
cout<<"ENTER ROLLNO, NAME, ADDRESS, AND CITY  OF STUDENT::";
cin>>rno>>nm>>add>>city;
}
    };
class lib
{
protected:
int bkno,edt;
char bknm[20],athr[10];
public:
void getchar()
{
cout<<"\nENTER BOOKNO,BOOKNM,AUTHOR AND EDITION OF BOOK:";
cin>>bkno>>bknm>>athr>>edt;
}
    };
class studreview:public stud,public lib
{
public:
void result()
{
cout<<"=================STUDENT/BOOK DETAIL============\n";
cout<<"ROLLNO:"<<rno<<"      \tBOOKNO:"<<bkno<<endl;
cout<<"NAME:"<<nm<<"       \tBOOK NAME:"<<bknm<<endl;
cout<<"ADDRESS:"<<add<<"    \tAUTHOR:"<<athr<<endl;
cout<<"CITY:"<<city<<"      \tEDITION:"<<edt<<endl;
cout<<"\n===============================================";
}
};
int main()
{
clrscr();
studreview s;
s.getdata();
s.getchar();
s.result();
getch();
return 0;
}
/*===========================================================
output
ENTER ROLLNO, NAME, ADDRESS, AND CITY  OF STUDENT::08mca23
XYS
atmiya
ank


ENTER BOOKNO,BOOKNM,AUTHOR AND EDITION OF BOOK:201
cpp
balagurusamy
4
=================STUDENT/BOOK DETAIL============
ROLLNO:         BOOKNO:201
NAME:XYS              BOOK NAME:cpp
ADDRESS:atmiya          AUTHOR:balagurusamy
CITY:ank        EDITION:4


===============================================
*/

No comments:

Post a Comment