Imagine a publishing company that markets both book and audiocassette versions of its works Create a class publication that stores the title (a string) and price (type float) of a publication from this class derive twn classet book, which adds a page count (type int), and tape, which adds a playing time in minutes (type float) Each of these three classes should have a getdatall function to get its data from the user at the keyboard, and a pudota) function to display its data.
#include <iostream.h>
#include <conio.h>
#include <stdio.h>
class publication
{
char title[20];
float price;
public:
void getdata() {
cout<<"Enter title: "; gets(title);
cout<<"Enter price: "; cin>>price;
}
void putdata()
{
cout<<"Title: "<>page_count;
}
void putdata()
{ publication::putdata();
cout<<"Page count: "<<page_count<<endl;
}
};
class tape:public publication
{
float play_time;
public:
void getdata()
{ publication::getdata();
cout<<"Enter Play time: ";
cin>>play_time;
}
void putdata()
{ publication::putdata();
cout<<"Play time: "<<play_time<<endl;
}
};
void main()
{
clrscr();
book b;
tape t;
b.getdata();
b.putdata();
t.getdata();
t.putdata();
getch();
}
Comments
Leave a comment