Write a program to declare a class ‘book’ containing data members as ‘title’, ‘author-name’, ‘publication’, ‘price’. Accept and display the information for one object using pointer to that object.
#include<iostream.h>
#include<conio.h>
class book
{
char author_name[20];
char title[20];
char publication[20];
float price;
public:
void Accept();
void Display();
};
void book::Accept()
{
cout<<"\n Enter book‟s title, author_name, publication and price \n:";
cin>> title >>author_name>> publication >> price;
}
void student::Display()
{
cout<<title <<”\t”<<author_name<<”\t”<<publication <<”\t”<<
price<<”\n”<<;
}
void main()
{
book b, *p;
clrscr();
p=&b;
p->Accept();
cout<<”title \t author_name \t publication \t price\n”;
p-> Display();
getch();
}