#include <iostream>
#include <string>
using namespace std;
class media
{
public:
media(string title_, double price_);
virtual void Display() = 0;
protected:
string title;
double price;
};
media::media(string title_, double price_) : title(title_), price(price_)
{}
class book : public media
{
public:
book(string title, double price, int numPages);
void Display();
private:
int numPage;
};
book::book(string title, double price, int numPages) : media(title, price), numPage(numPages)
{}
void book::Display()
{
cout << "Title " << title << " price " << price << " number of pages " << numPage << endl;
}
class tape : public media
{
public:
tape(string title, double price, double time);
void Display();
private:
double times;
};
tape::tape(string title, double price, double time) : media(title, price), times(time)
{
}
void tape::Display()
{
cout << "Title " << title << " price " << price << " time " << times << endl;
}
int main()
{
media *Book = new book("book", 350, 230);
Book->Display();
Book = new tape("tape", 420, 34);
Book->Display();
return 0;
}
Comments
Leave a comment