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:public stud
{
// 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;
}
void display()
{
cout<<"ROLLNO:"<<rno<<endl;
cout<<"NAME:"<<nm<<endl;
cout<<"ADDRESS:"<<add<<endl;
cout<<"CITY:"<<city<<endl;
cout<<"BOOKNO:"<<bkno<<endl;
cout<<"BOOK NAME:"<<bknm<<endl;
cout<<"AUTHOR:"<<athr<<endl;
cout<<"EDITION:"<<edt<<endl;
}
};
class studreview:public lib
{
public:
void result()
{
cout<<"=================STUDENT/BOOK DETAIL============\n";
display();
cout<<"\n===============================================";
}
};
int main()
{
clrscr();
studreview s;
lib l;
s.getdata();
s.getchar();
s.result();
getch();
return 0;
}
#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:public stud
{
// 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;
}
void display()
{
cout<<"ROLLNO:"<<rno<<endl;
cout<<"NAME:"<<nm<<endl;
cout<<"ADDRESS:"<<add<<endl;
cout<<"CITY:"<<city<<endl;
cout<<"BOOKNO:"<<bkno<<endl;
cout<<"BOOK NAME:"<<bknm<<endl;
cout<<"AUTHOR:"<<athr<<endl;
cout<<"EDITION:"<<edt<<endl;
}
};
class studreview:public lib
{
public:
void result()
{
cout<<"=================STUDENT/BOOK DETAIL============\n";
display();
cout<<"\n===============================================";
}
};
int main()
{
clrscr();
studreview s;
lib l;
s.getdata();
s.getchar();
s.result();
getch();
return 0;
}
No comments:
Post a Comment