Professional Documents
Culture Documents
Shahryar Qasim
Section: “A” 2nd Semester
21011556-041
REPORT TITLE
}
virtual void show()
{
}
};
class Name:public library
{
char name;
void get()
{
cout<<"\nName of the library : ";
cin>>name;
}
};
class schedule:public library
{
int timing;
void get()
{
cout<<"\n Schedule of the library = ";
cin>>timing;
}
};
class books
{
public:
int stock;
char author[20], publisher[20];
char bookname[20];
float price;
PAGE 2
REPORT TITLE
void loadbooks();
void display();
};
void books::loadbooks() //scope resolution operator to use public function from book
class
{
cout<<"\nName of the book you want :";
cin>>bookname;
cout<<"\nWritten by :";
cin>>author;
cout<<"\nPublished by :";
cin>>publisher;
cout<<"\nPrice of the book :";
cin>>price;
cout<<"\nStock present in the library :";
cin>>stock;
cout<<"\n******************\n";
}
void books::display() //scope resolution operator to use public function from book
class
{
cout<<"\nName of the Book:"<<bookname;
cout<<"\nAuthor of the Book:"<<author;
cout<<"\nPublisher of the Book:"<<publisher;
cout<<"\nPrice of the Book:"<<price;
cout<<"\nStock Present:"<<stock;
cout<<"\n******************\n";
}
int main()
{
library*ptr[2];
ptr[0]=new Name;
ptr[1]=new schedule;
for(int i=0;i<=2;i++)
{
ptr[i]->get();
ptr[i]->show();
cout<<endl;
}
books ob[10];
int ch, n;
do
{
PAGE 3
REPORT TITLE
cout<<"\n*******MENUE******\n";
cout<<"\n******************\n";
cout<<"\n1.Load Books\n2.Display\n3.Search\n4.Exit\n";
cout<<"\n\nEnter your Choice:";
cin>>ch;
switch(ch)
{
case 1: cout<<"Enter Number of Books:";
cin>>n;
for(int i=0;i<n;i++)
ob[i].loadbooks();
break;
case 2:
for(int i=0;i<n;i++)
ob[i].display();
break;
case 3:
PAGE 5