Imagine a publishing company that markets both book and audio cassette versions of its works.
Create a class called publication that stores the title(a string) and price(a float) of a publication. From this class derive two classes:book class, which contains a page count (type int); and tape class, which contains playing time(type int) in minutes. Each of these classes should have getdata() function to get its data from the user, and a putdata() function to display its data.
write a main () function to test the book and tape classes by creating instances of them, asking the user to fill data with getdata(), and the displaying the data with putdata() through menus.
write a main ()function that displays a menu as below.
main menu: a) enter data
b)view data
c) exit
after taking the option for 'a' and 'b' options, another menu is to be displayed as data item is book/tape(b/T):
make program is attached below please correct the problem i am having.
#include <iostream>
#include <string>
using namespace std;
class publication
{
private:
string title;
float price;
public:
publication(); //constructor
void getData()
{
system ("cls");
cout<<"\nEnter the title:";
getline(cin,title);
//output data according to choice
cout << "\n\nDISPLAY MENU\n";
cout << "------------\n";
cout << "1 - Book\n";
cout << "2 - Tape\n";
cout << "\nAny other key to Exit==>";
getchar(); //buffer
choice = getchar();
if (choice == '1'){ //display book info
playbook.publication::putData();
playbook.book::putData();
}
else
if (choice == '2'){ //display tape info
playtape.publication::putData();
playtape.tape::putData();
}
else
cout << "\n\nGoodbye!";