Write
a C++ program to create a class Book which contains data members as
B_id,B_name,B_author,B_publication. Write member functions to accept and
display Book information also display count of Books. (Use static data member
to maintain Count of Books.)
#include<iostream.h>
#include<conio.h>
class Book
{
int B_id;
char B_name[20];
char B_author[20];
char B_publication[20];
public:
void getdata();
void putdata();
};
void Book::getdata()
{
cout<<"\n\nEnter the
Book_id:";
cin>>B_id;
cout<<"\nEnter the name of the
Book:";
cin>>B_name;
cout<<"\nEnter the name of the
author:";
cin>>B_author;
cout<<"\nEnter the
Publication:";
cin>>B_publication;
cout<<"\n************************************";
}
void Book::putdata()
{
static int count=0;
cout<<"\n1.Book_id:"<<B_id;
cout<<"\n2.Book
Name:"<<B_name;
cout<<"\n3.Book
Author:"<<B_author;
cout<<"\n4.Publication:"<<B_publication;
count++;
cout<<"\nCount of
Books:"<<count;
cout<<"\n***********************************";
}
int main()
{
int i,n;
clrscr();
Book b[10];
cout<<"\n*********** Accepting
Details ***********";
cout<<"\nHow many records you
want to enter:";
cin>>n;
for(i=0;i<n;i++)
{
b[i].getdata();
}
for(i=0;i<n;i++)
{
b[i].putdata();
}
getch();
return 0;
}