Reference no: EM13164959
A company that market is publishing both book and audiocassette versions. Below is an
implementation of the class publication.
Hint: Separate class interface from the implementation.
#include <iostream>
#include <string>
using namespace std;
class publication
private:
string title;// publication that stores the title (a string)
float price; // price (type float) of a publication
public:
publication(){title =""; price=0 }
publication(string t, float p){ title=t; price=p;}
void getdata()
{
cout << "\nEnter title: "; cin >> title;
cout << "Enter price: "; cin >> price;
}
void putdata() const
{
cout << "\nTitle: " << title;
cout << "\nPrice: " << price;
}
From this class derive two classes:
1- Class Book which contains:
i) A parameterized constructor that initializes its entire data in addition to the base
ii) Data member page count of type int.
iii) getdata() function to get its data from the user at the keyboard.
iv) putdata() function to display its data.
2- Class Tape which contains:
i) A parameterized constructor that initializes its entire data in addition to the base
ii) Data member playing time in minutes of type float.
iii) getdata() function to get its data from the user at the keyboard.
iv) putdata() function to display its data.
3- Write a main() program to test the book and tape classes by creating instances of
them, set the data and print it.
class data members.
class data members.