Answer to Question #271419 in C++ for Shabu

Question #271419

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.

1
Expert's answer
2021-11-25T11:32:56-0500
#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();
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS